Home / Secret Key Generators / NextAuth

NextAuth NEXTAUTH_SECRET Generator

Generate a NEXTAUTH_SECRET for NextAuth.js (Auth.js): a base64-encoded 32-byte value, the format the project’s own docs recommend, entirely in your browser.

100% client-side No account, no sign-up Base64, 32 bytes, matches official docs

NEXTAUTH_SECRET Generator

Click Generate to create one.

Or generate it on the command line

NextAuth’s own documentation recommends generating this with OpenSSL, if you’d rather do it locally:

$ openssl rand -base64 32

Set it as NEXTAUTH_SECRET in your environment variables (.env.local for development, your host’s secret manager for production). Never commit it to source control.

How this tool works

This matches NextAuth.js’s (Auth.js’s) documented recommendation: a base64-encoded 256-bit (32-byte) random value, the same output openssl rand -base64 32 produces. This tool generates it via the Web Crypto API’s crypto.getRandomValues() in your browser.

Sources:

Frequently asked questions

What is NEXTAUTH_SECRET used for?

It’s used to sign and encrypt session tokens and JWTs in NextAuth.js / Auth.js. Without it set explicitly, NextAuth may fall back to a less secure default in some configurations. Always set it explicitly for production.

Is NEXTAUTH_SECRET the same as AUTH_SECRET?

Auth.js (the successor project to NextAuth.js) renamed the variable to AUTH_SECRET, but it serves the same purpose and the same generation method applies to both.