Environment variables
Environment variables are named values your app can reuse, with a different value for each environment: Development (editor and preview), Staging (the /s/ test copy) and Production (the live app). Plain variables hold non-sensitive settings such as a public client id or an API ba
Environment variables are named values your app can reuse, with a different value for each environment: Development (editor and preview), Staging (the /s/ test copy) and Production (the live app). Plain variables hold non-sensitive settings such as a public client id or an API base URL; anything sensitive belongs in a secret.
When to use
- An API source that should call a sandbox URL while testing and the real URL when live.
- A public identifier that differs between test and live accounts (
GOOGLE_CLIENT_ID). - A value you want to change in one place rather than in several components or workflows.
Variables versus secrets
| Variables | Secrets | |
|---|---|---|
| Example | API_BASE_URL, GOOGLE_CLIENT_ID | STRIPE_SECRET_KEY, RESEND_API_KEY, DATABASE_URL |
| Visible after saving | Yes, to editors | Never (write-only) |
| Included in the published app configuration | Yes | No, server-side only |
| Who can manage | Editors | Admins and owners |
If a variable name looks sensitive (contains SECRET, PASSWORD, TOKEN, PRIVATE or ends with _KEY), the form warns you to store it as a secret instead.
How to add a variable
- Open Settings › Environment & secrets.
- Pick the environment tab: Development ("Used in the editor and preview"), Staging ("Used by test publishes"), or Production ("Used by your live, published app"). Each tab shows how many values it holds.
- In the Variables card, enter a name in capitals with digits and underscores, starting with a letter (
API_BASE_URL; lowercase is converted as you type), and a value (up to 2,000 characters). - Click Add variable. Edit a value in place later; it is saved when you leave the field.
- Repeat for the other environments: each environment has its own values, and a variable that exists only in Development is empty in Production.
The Common chips (GOOGLE_CLIENT_ID, and secret suggestions) pre-fill the name.
Using a variable
Where a setting accepts a template, reference the variable with {{env.NAME}}, for example in an API source URL: {{env.API_BASE_URL}}/orders. The runtime substitutes the value of the current environment on the server.
Development API_BASE_URL = https://sandbox.api.example.com Staging API_BASE_URL = https://sandbox.api.example.com Production API_BASE_URL = https://api.example.com
Deleting a variable
Click the trash icon and confirm. "Anything that reads it will get an empty value."
Common mistakes
- Setting a value in Development only. Preview works, the live app does not. Fill Staging and Production too; the publish checklist reports missing API secrets but not missing plain variables.
- Storing a password as a variable. Variables reach the browser as part of the published configuration. Use a secret.
- Expecting changes to apply to the live app without publishing. Plain variables are part of the project definition; publish after changing a Production value.
Advanced
Variables are stored in project.environments[].variables as { key, secret: false, value } and changed with the set_env_variable / delete_env_variable commands (editors; excluded from the AI). The runtime context pins the environment key per channel (development for draft, staging for staging, production for live). Google sign-in in apps reads GOOGLE_CLIENT_ID (variable) and GOOGLE_CLIENT_SECRET (secret) from the environment being published.