Use 1Password secrets in .env files

Use 1Password secret references in .env files and resolve them securely at runtime.

Dotenvx resolves op:// references before injecting them into your command.

Prerequisites

To get the most out of this guide, you'll need to:

1. Install

Get the Dotenvx CLI.

$ curl -sfS https://dotenvx.sh | sh
◈ installed (dotenvx)

more install options

2. Add a secret reference

Reference a secret from your 1Password vault.

$ echo "HELLO=op://Personal/hello/password" > .env

3. Run

Run your command with the secret resolved from 1Password.

$ dotenvx run -- sh -c 'echo Hello $HELLO'
Hello World