DocumentationLearnEncryptingMultiple Environments

Multiple Environments

Use encrypted env files across multiple environments.

Use the same encryption workflow for each environment. Create a .env.ENVIRONMENT file, encrypt it, and decrypt it at runtime with -f.

# .env.production
HELLO="Production"
$ dotenvx encrypt -f .env.production
◈ encrypted (.env.production)

Run with the same file.

$ dotenvx run -f .env.production -- node index.js
⟐ injected env (2) from .env.production
Hello Production

This keeps each environment's values separate while preserving the same encrypted-file workflow.