Node.js

Encrypt a .env file in Node.js with the Dotenvx SDK, commit it safely, and load its secrets at runtime.

1. Install

Get the Dotenvx Node.js SDK.
$ npm install @dotenvx/dotenvx

2. Encrypt

Encrypt your .env file.

$ npx dotenvx encrypt

3. Inject

Then inject your encrypted secrets at runtime.
require('@dotenvx/dotenvx').config()

console.log(`HELLO: ${process.env.HELLO}`)