Securely manage API keys, secrets, and configuration for your applications across different environments.
Environment variables are key-value pairs that store configuration and secrets outside your codebase. They allow you to customize your application's behavior without changing code.
Store sensitive credentials securely
Different databases for dev, staging, production
Enable/disable features per environment
App settings that change by environment
You can add environment variables through the dashboard or using the CLI.
Add a single variable:
cupadev env add API_KEY your-secret-key --productionImport from .env file:
cupadev env pullCupaDev supports three environment scopes, allowing you to use different values in each:
Used for deployments from your main/master branch. These are your live production values.
DATABASE_URL=postgresql://prod.example.comUsed for all non-production branch deployments. Ideal for staging and testing.
DATABASE_URL=postgresql://staging.example.comUsed when running your app locally with cupadev dev command.
DATABASE_URL=postgresql://localhost:5432CupaDev automatically injects these environment variables into all deployments:
| Variable | Description |
|---|---|
| CUPADEV_ENV | production, preview, or development |
| CUPADEV_URL | The deployment URL |
| CUPADEV_GIT_COMMIT_SHA | Git commit hash |
| CUPADEV_GIT_COMMIT_MESSAGE | Git commit message |
| CUPADEV_GIT_BRANCH | Git branch name |
| CUPADEV_REGION | Deployment region |
How to access environment variables depends on your framework:
Prefix with NEXT_PUBLIC_ for client-side access:
// Server-side const apiKey = process.env.API_KEY; // Client-side (must prefix with NEXT_PUBLIC_) const publicKey = process.env.NEXT_PUBLIC_STRIPE_KEY;
Prefix with VITE_:
const apiUrl = import.meta.env.VITE_API_URL;
const dbUrl = process.env.DATABASE_URL;
Never commit .env files or hardcode secrets in your source code. Always use environment variables.
Add to .gitignore:
.env.env.local.env.*.localMark sensitive variables as "Secret" in the dashboard. They will be encrypted and hidden from logs.
Change your API keys and secrets periodically, especially if team members leave or if there's a potential security breach.
Always use separate API keys and database credentials for production, preview, and development environments.
Make sure you've added the variable to the correct environment scope and redeployed. For client-side access, remember to prefix with NEXT_PUBLIC_ or VITE_.
Environment variables are injected at build time. You must trigger a new deployment for changes to apply.
Environment variables are set at build time and cannot be changed without redeployment. For runtime configuration, consider using a remote config service.