Better Auth Secret Generator

Better Auth signs sessions with BETTER_AUTH_SECRET. Generate a strong one here and paste it into your environment.

BETTER_AUTH_SECRET

Generating in your browser…

Generated on your device with the Web Crypto API. Never sent or stored.

.env line
BETTER_AUTH_SECRET=""

Prefer the terminal?

  • OpenSSL
    openssl rand -base64 32

How to use your BETTER_AUTH_SECRET

Copy the value above and add it to your .env file and to the environment variables of every place the app runs. Keep it out of source control: commit an .env.example with an empty value instead, and set the real value in your hosting provider's environment settings or a secrets manager.

Better Auth uses the secret for encryption, signing and hashing. It should be at least 32 characters of high-entropy randomness; this page gives you 32 random bytes encoded as base64, which is 44 characters.

Is it safe to generate secrets in a browser?

Only if the secret is created locally, which is how this page works. The value comes from crypto.getRandomValues, the same cryptographically secure source browsers use for TLS keys, and it never leaves your device: there is no network request, log or analytics event that includes it.

If you prefer the command line, the commands on this page produce an equivalent secret on your own machine. Either way, use a different secret for development, staging and production, and rotate it straight away if it ever appears in a log, a screenshot or a public repository.

Frequently asked questions

Can I reuse the same secret across environments?

Don't. Use a different secret for development, staging and production so a leak in one doesn't expose the others.