RandomKeygen

Local-only · Auth.js v5 & NextAuth v4

NextAuth / Auth.js Secret Generator

Generate cryptographically secure AUTH_SECRET (Auth.js v5) and NEXTAUTH_SECRET (NextAuth v4) values for JWE session cookies and CSRF tokens — never transmitted off your device.

AUTH_SECRET

0weak 40ok 64strong 80128+ bits
Excellent · 256 bitsCalculating…
Click any secret to copy & select for snippets · R regeneratesAUTH_SECRET=…
Entropy256 bits32 random bytes from Web Crypto
Env variableAUTH_SECRETAuto-detected by Auth.js v5
Output length44 charsStandard Base64 (matches npx auth secret)

Add it to your app

Live-synced to your selected secret and environment variable name.

3-step production setup

From local development to zero-downtime key rotation.

01
Generate at least 32 random bytesAuth.js derives AES-256-GCM encryption keys via HKDF from AUTH_SECRET. Use a full 32-byte Base64 (44-char) or Hex (64-char) secret with 256 bits of CSPRNG entropy.
02
Store in .env.local & hosting vaultPaste AUTH_SECRET into .env.local for local dev (never commit it) and set a completely separate value in Vercel, Cloudflare, or your production secrets manager.
03
Rotate without logging everyone outAuth.js v5 supports key rotation via AUTH_SECRET_1, AUTH_SECRET_2 (or an array in config): new cookies encrypt with the newest key while old cookies still verify.