Build

Environment Variables

Where your project keeps its API keys and settings, with one value for the editor and one for the published app.

An environment variable is a named value your app reads when it runs: an API key, a webhook secret, the address of a service. You keep them out of the code so the key can change without the app changing, and so a secret is not sitting in a file.

Open the panel

In your project, click + next to the tabs and pick Env variables. The tab is titled Environment Variables and lists every variable of this project. Variables belong to one project: another project never sees them.

Add a variable

  1. 1
    Click Create
  2. 2
    Name it
  3. 3
    Give it its values
  4. 4
    Choose its target
  5. 5
    Click Create

You do not always have to start here. When the agent builds something that needs a key, it declares the variable itself and the chat shows Environment Variables Required with a Set Environment Variables button that brings you to this panel.

Development and production

The selector at the top of the panel switches the list between Development and Production. Use it to give the published app a different key from the one you test with: a Stripe test key while you build, the live key in production.

A variable with no value shows a small empty label on its row.

Frontend or backend

TargetWho can read the valueUse it for
BackendOnly your serverSecret keys: payment secrets, e-mail and AI provider keys, anything that must stay private
FrontendEvery visitor's browserPublic values only: a publishable key, a public project URL, an analytics ID

A frontend variable is compiled into the pages your visitors download, under a VITE_ prefix. Anyone can read it. A Website has no server, so every variable it uses is a frontend one: never give a Website a secret key. If your app must call a paid API with a secret, it needs a backend.

Edit, hide, delete

  • Values are masked. The eye icon shows one.
  • Change a value in its row, then click Save or press Enter.
  • The bin icon deletes a variable, after a confirmation. This cannot be undone.

Variables Capacity fills for you

Some rows carry a lock and the label Filled by Capacity. They connect your app to what Capacity provides, such as its database and its file storage, and you cannot edit them. You do not need to create a DATABASE_URL yourself for a backend: it is already there.

When a change takes effect

  • In the editor: at once. A Website is rebuilt and its preview refreshed; a project's server restarts. You have nothing to restart yourself.
  • In the published app: at the next publish. Change the production value, then click Update in the top bar.

Good habits

  1. Add the key before asking for the feature, and name it the way the service's own documentation does (RESEND_API_KEY, STRIPE_SECRET_KEY). The agent then finds it.
  2. Give production its own keys.
  3. Keep secrets on the Backend target.
  4. If a key has been shown on a screen share or pasted somewhere public, revoke it at the provider and put the new one here.

Troubleshooting

The published app does not see the new value. Publish again: production values are read when the app is published.

The name is refused. It must start with an uppercase letter and contain only uppercase letters, digits and underscores.

The agent does not use my variable. Say so plainly: "Use the RESEND_API_KEY environment variable I added."