Keep your private keys in 1Password
Add 1Password to your Dotenvx installation.
$ dotenvx install --add 1password
Set up 1Password CLI (op version 2).
Sign in to 1Password CLI with an account that can create items in your vault. Follow the 1Password CLI setup guide for your sign-in method.
Sign in on each machine that needs access.
From the project directory containing your .env file, encrypt and choose more, then 1Password when prompted.
$ dotenvx encrypt
Dotenvx encrypts your .env file and stores the private key in 1Password. Commit the encrypted .env file with your code.
For .env.production, add -f .env.production.
Already using .env.keys? Follow the 1Password migration guide to move your existing private key instead.
When you run your app, Dotenvx reads the private key through the signed-in 1Password CLI and loads your decrypted environment variables.
$ dotenvx run -- node index.js
Run from the same project directory. Replace node index.js with your app’s start command.
That’s it! Your app now loads encrypted secrets with the private key stored in 1Password.