How to manage environment variables across dev, staging and prod
The same keys, different values, different people allowed to change them. Here is a setup that keeps environments separate without keeping a pile of .env.staging files.
The problem
Multiple .env files multiply quickly: .env.dev, .env.staging, .env.prod, plus local overrides. Nobody is sure which one is current, and a key added to one is forgotten in the others.
Production is the dangerous one. If everyone can read and write it, one wrong command touches live data.
How to do it with SnapEnv
Use one project with several environments
A SnapEnv project starts with dev, staging and prod. Each variable is scoped to an environment, so DATABASE_URL in prod is independent of DATABASE_URL in staging.
Pull the one you need
Choose the environment at pull time instead of juggling files.
snapenv pull --env staging
Compare environments to find drift
Diff checks which keys differ between environments server-side, without returning the values.
snapenv diff --env dev,prod
Protect production
Production is protected by default. Developers and Read-only members get no access to it unless an Owner or Admin grants an explicit per-environment permission.
Avoid duplicating values
Reference one variable from another with ${VAR} syntax. Change it once and everything that points to it follows.
APP_URL=https://app.example.com API_URL=${APP_URL}/api
Frequently asked questions
Can I add environments beyond dev, staging and prod?
Yes. Add any environment from the project settings, such as qa, canary or eu-prod, and mark it protected if it needs the same restrictions as production.
Can I copy variables between environments?
Yes. The dashboard supports copying variables between environments, and you can push a local file to any environment with snapenv push.
Can I see what changed in a variable?
Yes. Each variable keeps its history, you can roll back to a previous value, and the audit log records who changed it and when.
Free for small teams. Set up in minutes.
3 projects, 3 members, full CLI and Kubernetes operator. No credit card.