Overview
Environment variables let you store configuration and secrets (like API keys) separately from your code.Add environment variables
1
Go to your project
Navigate to your project from the dashboard.
2
Open Settings
Click the Settings tab in your project.
3
Add variable
Scroll to Environment Variables, enter a Key and Value, then click Add.
4
Save
Click Save Changes to apply. Your variables will be available on the next deployment.
Sensitive values
Environment variable values are masked in the dashboard UI (shown as••••••••) for security.
Accessing variables
Environment variables are available asprocess.env in your code:
Build vs runtime variables
| When available | Use for |
|---|---|
| Build time | API URLs, feature flags, public keys |
| Runtime | Secrets, database URLs, private keys |
Common variables
| Variable | Description |
|---|---|
DATABASE_URL | PostgreSQL connection string (auto-added) |
NODE_ENV | Set to production automatically |
PORT | Port your app should listen on |
Reserved variables
These variables are set automatically and cannot be overridden:NODE_ENV— AlwaysproductionPORT— Assigned dynamically
Best practices
- Never commit secrets — Use environment variables instead of
.envfiles in production - Use environment variables for sensitive data — API keys, passwords, tokens
- Use descriptive names —
STRIPE_SECRET_KEYnotKEY1 - Rotate regularly — Update secrets periodically for security