Envs
There is built-in support for environment variables with Deno.env.
There are getter and setter methods.
Deno.env.set("FIREBASE_API_KEY", "examplekey123");
Deno.env.set("FIREBASE_AUTH_DOMAIN", "firebasedomain.com");
console.log(Deno.env.get("FIREBASE_API_KEY")); // examplekey123
console.log(Deno.env.get("FIREBASE_AUTH_DOMAIN")); // firebasedomain.com
console.log(Deno.env.has("FIREBASE_AUTH_DOMAIN")); // trueSpecial Deno Environment Variables
Check here.
.env Files
.env FilesYou can cause Deno to read environment variables from .env using the --env-file flag.
This will read .env by default.
deno run --env-file <script>If you want or need to load environment variables from a different file, you can specify that file as a parameter to the flag.
When multiple declarations for the same environment variable exist within a single .env file, the first occurrence is applied.
However, if the same variable is defined across multiple .env files (using multiple --env-file arguments), the value from the last file specified takes precedence.
Last updated