Environment Variables
Environment variables in Build are managed at three levels: project defaults (in build.json), sandbox secrets (encrypted), and runtime overrides (per-session).
Project Defaults
Define default environment variables in the build.json file. These are included in every sandbox and preview:
Secrets
Sensitive values (API keys, database credentials) should be stored as secrets rather than in build.json. Secrets are encrypted at rest and never exposed in logs or previews:
!Warning
Never put secrets in build.json. The file is visible in the sandbox filesystem and may appear in agent logs. Use the Secrets UI for all sensitive values.
Preview Environment Variables
Each preview deployment can override environment variables. This is useful for feature branches that connect to different backends:
Variable Precedence
When the same variable is defined at multiple levels, the highest priority wins:
- Runtime overrides (set via agent or shell in the current session)
- Preview environment variables
- Secrets
- Project defaults in build.json