Skip to content
On this page

Environment Variables ​

The following basic examples show how to work with environment variables. Deno provides support for environment variables natively. The Deno.env object provides methods to get, set, delete, and list environment variables.

Default Environment Variables ​

Netzo will inject a set of default environment variables to the project at runtime.

json
{
  "DENO_DEPLOYMENT_ID": "63be692a877dce879a4604bd-63bf3ad110ea82bec8916dd1",
  "DENO_REGION": "europe-west9",
  "NETZO_ENV": "production",
  "NETZO_PROJECT_ID": "63be692a877dce879a4604bd",
  "NETZO_PROJECT_HASH": "63bf3ad110ea82bec8916dd1",
  "NETZO_PROJECT_ENTRYPOINT": "main.ts",
  "NETZO_PROJECT_ENTRYPOINT_URL": "https://api.netzo.io/projects/63be692a877dce879a4604bd/main.ts",
  "NETZO_PROJECT_IMPORT_MAP": "import_map.json",
  "NETZO_PROJECT_IMPORT_MAP_URL": "https://api.netzo.io/projects/63be692a877dce879a4604bd/import_map.json"
}
{
  "DENO_DEPLOYMENT_ID": "63be692a877dce879a4604bd-63bf3ad110ea82bec8916dd1",
  "DENO_REGION": "europe-west9",
  "NETZO_ENV": "production",
  "NETZO_PROJECT_ID": "63be692a877dce879a4604bd",
  "NETZO_PROJECT_HASH": "63bf3ad110ea82bec8916dd1",
  "NETZO_PROJECT_ENTRYPOINT": "main.ts",
  "NETZO_PROJECT_ENTRYPOINT_URL": "https://api.netzo.io/projects/63be692a877dce879a4604bd/main.ts",
  "NETZO_PROJECT_IMPORT_MAP": "import_map.json",
  "NETZO_PROJECT_IMPORT_MAP_URL": "https://api.netzo.io/projects/63be692a877dce879a4604bd/import_map.json"
}

Runtime Environments ​

Netzo supports two runtime environments for projects: production and preview. The corresponding environment variables will be injected to the project at runtime and NETZO_ENV will be set to either production or preview.

  • Production: https://{uid}.netzo.io
  • Preview: https://{deploymentId}.netzo.io

Deno.env.get() ​

Get the value of an environment variable. Returns undefined if the variable is not defined.

ts
const name = Deno.env.get('NAME')
const name = Deno.env.get('NAME')

Deno.env.set() ​

Set the value of an environment variable.

ts
Deno.env.set('NAME', 'John')
Deno.env.set('NAME', 'John')

Deno.env.toObject() ​

Get a copy of the environment variables as an object.

ts
const env = Deno.env.toObject()
const env = Deno.env.toObject()

Deno.env.delete() ​

Unset the value of an environment variable.

ts
Deno.env.delete('NAME')
Deno.env.delete('NAME')