Manage multiple environments
Manage multiple environments like
.env.production with this quickstart guide.
# production HELLO="Production"
.env.production to its env vault.
Run the push command with the environment argument.
npx dotenv-vault push production
This securely pushes your
.env.production secrets to your project vault's production environment.
Next, let's view your secrets in the UI.
Run the open command to view your production environment variables in the UI.
npx dotenv-vault open production
Just like the push command, you pass an additional production environment argument to open directly to that environment's secrets.
Make a change in the UI and then pull the latest
npx dotenv-vault pull production
Solid! You completed this quickstart guide – managing your secrets across multiple environments. I recommend learning how to load
.env files in development next.
Run the help push and help pull commands to see how you can further customize these commands.
npx dotenv-vault help push npx dotenv-vault help pull
For example, a common need is to pull production secrets to a normal .env file. You can do so with this command.
npx dotenv-vault pull production .env
Every project comes with four default environments and their corresponding
- development =>
- ci =>
- staging =>
- production =>
You can push to each one by appending the environment name after push.
npx dotenv-vault push development npx dotenv-vault push ci npx dotenv-vault push staging npx dotenv-vault push production
The same for pulling. Append the environment name after pull.
npx dotenv-vault pull development npx dotenv-vault pull ci npx dotenv-vault pull staging npx dotenv-vault pull production
You can push and pull a different filename to each one by further appending the filename after the environment argument.
npx dotenv-vault push development .env.local npx dotenv-vault pull ci secrets.txt npx dotenv-vault push staging any-filename npx dotenv-vault pull production .env
In some automation scenarios, you might not have a
.env.me file present. In those cases you can pass the value of your
DOTENV_ME credential to the cli using the
npx dotenv-vault pull --dotenvMe=me_1z1z1z
Big congrats! You have advanced knowledge now – when it comes to managing multiple environments and using the push and pull commands.