Encrypt a .env file in Bun
Encrypt a .env file in Bun with the Dotenvx Node.js SDK, commit it safely, and load its secrets at runtime.
1. Install
Install the Dotenvx Node.js SDK with Bun.
$ bun add @dotenvx/dotenvx
2. Encrypt
Encrypt your .env file.
$ bunx dotenvx encrypt
◈ encrypted (.env)3. Inject
Then inject your encrypted secrets at runtime.
index.js
require('@dotenvx/dotenvx').config()
console.log(`HELLO: ${process.env.HELLO}`)