Environment variables

The configuration your app reads from its environment.

API keys, database URLs, feature flags, NODE_ENV. Deplo stores them encrypted and injects them at build time and at run time.

The four layers

When a name is set in more than one layer, the highest one wins:

  1. A shared variable added automatically: one shared with two or more teams, or an instance-wide one. It shows on the app, read-only.
  2. The app's own variables.
  3. A shared variable the app has linked.
  4. A preview override, on previews only.

Plain and secret

PlainSecret
Shown againYesNever, in the panel or the API
Edit or renameYesNo: delete it and add it again
Change the typeTo secret: Edit, or Make Secret on selected rowsNever back to plain

A plain name that looks like a credential gets a warning icon: DB_PASSWORD, API_TOKEN, S3_ACCESS_KEY_ID. A name holding PUBLIC, FILE or VERSION is not flagged.

Set variables on one app

Open Environment

Open the app, then Environment, and click Add.

One app's Environment tab with its variables, sources and secret values

Name it and set the type

A name and a value per row. Turn on Secret for a credential.

The Add environment variables dialog, key and value rows plus the Secret switch
  • Paste a whole .env into the Key field to add every line at once, as plain.
  • Names use letters, digits and underscores, and do not start with a digit.
  • The other tabs: Shared links a shared variable, Database a managed database's connection string.

Variables apply on the next deploy: use Redeploy on the Changes not deployed yet notice.

Build time

A Railpack build gets every variable, so NEXT_PUBLIC_* and VITE_* work as they are. Two limits:

  • A Dockerfile build sees only the names it declares, like ARG NEXT_PUBLIC_API_URL. Docker keeps build arguments in the image history, readable with Docker access to the build server.
  • Names that configure the build host never reach it: PATH, HOME, and DOCKER_*, BUILDKIT_*, BUILDX_*, COMPOSE_*, LD_*, XDG_*, among others.

See everything at once

Variables in the sidebar has two tabs:

  • All: every app's variables, grouped by project and app, with search and filters.
  • Shared: the team's shared variables, plus the ones other teams share with it.
The team-wide Environment Variables page grouped by project

Preview overrides

With pull request previews on, the app's Environment page gets a collapsed Preview overrides section: values used by previews only, above every other layer. Typical use: point previews at a test database.

A preview built from a fork inherits nothing

For security reasons it gets only the plain preview overrides. If your app needs DATABASE_URL to start, set it there as plain.

Good to know

  • No secret variable can be revealed, not even with reveal_secrets. That capability covers database connection strings, backup recovery keys and app backup downloads.
  • Deplo does not know which names your app reads. A typo is a missing variable at run time.
  • Compose apps get the variables in every service. A key the compose file sets itself keeps the compose value.

Troubleshooting

SymptomWhat to check
The app cannot see a variableIt was added after the last deploy. Redeploy.
The value is right in Deplo and wrong in the appA higher layer sets the same name: a linked shared variable, a preview override, or the compose file.
A build-time variable is empty in the browser bundleThe framework only inlines prefixed names (NEXT_PUBLIC_, VITE_). With a Dockerfile, declare it with ARG.

More in Deploys and builds.

Next steps

Did this page help you?

On this page