deploy/reference/env_vars_and_contexts.md
Environment variables in Deno Deploy allow you to configure your application with static values such as API keys or database connection strings.
Environment variables can be stored as:
Variables can be set at:
Each environment variable applies to one or more contexts. Contexts represent the logical "environments" in which your code runs, each with its own set of variables and secrets.
By default, there are two contexts:
:::info
Need additional contexts? Please contact support.
:::
Additionally, there is a Build context used during the build process. Environment variables in the Build context are only available during builds and aren't accessible in Production or Development contexts (and vice versa). This separation enables different configuration for build-time vs. runtime.
Within a single application or organization, you cannot have multiple environment variables with the same name in the same context. You can, however, have variables with the same name in different non-overlapping contexts.
You can manage environment variables from several locations:
In each location, click the relevant edit button to open the environment variables drawer. Changes only apply when you click "Save." Clicking "Cancel" discards your changes.
To add a variable:
You can also bulk import variables from a .env file:
.env fileNote that lines starting with # are treated as comments.
To remove a variable, click the "Remove" button next to it.
To edit a variable, click the "Edit" button next to it to modify its name, value, secret status, or applicable contexts.
Access environment variables using the Deno.env.get API:
const myEnvVar = Deno.env.get("MY_ENV_VAR");
Environment variables have the following limits:
DENO_, except for DENO_AUTH_TOKENS, DENO_COMPAT, DENO_CONDITIONS,
DENO_DEPLOY_ENDPOINT, or DENO_DEPLOY_TOKENLD_OTEL_AWS_ROLE_ARNAWS_WEB_IDENTITY_TOKEN_FILEGCP_WORKLOAD_PROVIDER_IDGCP_SERVICE_ACCOUNT_EMAILGCP_PROJECT_IDAZURE_CLIENT_IDAZURE_TENANT_IDAZURE_FEDERATED_TOKEN_FILEDeno Deploy provides these predefined environment variables in all contexts:
DENO_DEPLOY: true - Indicates that the code is running in Deno Deploy.DENO_DEPLOY_ORGANIZATION_ID: The ID of the organization that owns the
application. This is a UUID.DENO_DEPLOY_ORGANIZATION_SLUG: The slug of the organization that owns the
application. This is the human-readable identifier used in URLs that was set
when creating the organization.DENO_DEPLOY_APPLICATION_ID: The ID of the application. This is a UUID.DENO_DEPLOY_APPLICATION_SLUG: The slug of the application. This is the
human-readable identifier used in URLs that was set when creating the
application, or changed later in the application settings.DENO_DEPLOY_BUILD_ID: The ID of the currently running build.DENO_DEPLOYMENT_ID: A unique identifier representing the entire
configuration set (application ID, build ID, context, environment variables,
cloud connections, database). Changes if any of these components change.DENO_DEPLOY_BUILD_ID: The ID of the currently running revision.DENO_TIMELINE: The timeline the application is currently running in.
Possible values are production, git-branch/<branch-name>, and
preview/<revision-id>. This is not set during builds, as builds are not
specific to any timeline.During builds, the environment variable CI=1 is additionally set.