Next.js
Load encrypted .env files with the Next.js environment loader.
Package
Install
npm install @dotenvx/next-env
Add an override to your app’s package.json.
{
"overrides": {
"@next/env": "npm:@dotenvx/next-env"
}
}
Run npm install again to apply the override.
Usage
Start Next.js with npm run dev. Next.js loads .env through @dotenvx/next-env and makes the values available to server-side code through process.env.
See the Next.js quickstart for pnpm setup and deployment.