Configuration
Environment variables
Add and edit environment variables, when changes take effect, why they aren't available at build time, PORT, and connecting databases.
Edit variables
- Project Environment tab → Add variable, enter KEY and value (eye icon shows or hides values).
- Save ("Redeploy for the app to pick them up").
- General tab → Deploy.
- Names: letters, digits, underscores, not starting with a digit (e.g.
DATABASE_URL); each name once. - Values are stored exactly as typed; don't add quotes unless they're part of the value.
- Saving replaces the whole list with what's on screen. Unsaved edits trigger a warning if you leave.
- Editing needs the Developer role or higher.
When changes apply
Variables are applied when a container is created: every Deploy, Rebuild or rollback. Reload keeps the old variables.
Runtime only
Variables are not available during the build (Nixpacks, docker build, Buildpacks). This affects:
- build-time framework variables (
NEXT_PUBLIC_*,VITE_*,REACT_APP_*), - build steps needing secrets (private registry tokens).
Put non-secret build values in nixpacks.toml ([variables]) or the Dockerfile, or build in CI and use Deploy from Image. For Compose projects, variables go into a .env beside the compose file (${VAR} or env_file: .env).
PORT
Unset PORT defaults to 3000. Your app must listen on 0.0.0.0:$PORT. Set it for images with a fixed port (e.g. PORT=80 for nginx). See Ports and health checks.
Connecting a database
Copy the Connection URL under Connect your deployed apps (private network) on the database page, add it as DATABASE_URL (or REDIS_URL, MONGODB_URI…), and deploy.
Privacy
MarvX Assistant and the AI build debugger never see variable values (the debugger sees names only). Preview deployments reuse production variables.
API
GET /v1/apps/{id}/env lists variables. PUT /v1/apps/{id}/env with {"vars": [{"key": "PORT", "value": "3000"}]} replaces the list: anything omitted is deleted. Use a personal token (API tokens).