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")); // true

Special Deno Environment Variables

Check herearrow-up-right.

.env Files

You 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.

circle-exclamation

Last updated