Encrypt secrets in Bun

Learn how to encrypt your first .env file using Bun and the Dotenvx Node.js SDK.

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}`)