Keeping secrets safe
When it comes to keeping secrets such as API keys or database credentials safe, SvelteKit has us covered. As we saw in Chapter 9, we can import .env
secrets from $env/static/private
. But this is not the only module that allows us to import environment variables. In this section, we’ll examine more modules and how they all can help us import environment variables as well as secrets.
$env/static/private
Beginning with the module we’ve already used, $env/static/private
is great for importing environment variables like those specified in .env
files or those set when starting the runtime. For instance, if we were to start our application with the API_KEY="" node index.js
command, the API_KEY
variable would be available, just as GITHUB
was available after we imported $env/static/private
in Chapter 9. Any environment variables provided when starting the application will override the value of those provided in a .env
file. The variables from...