LeakLatch

Blog · November 19, 2026

NEXT_PUBLIC_ secrets stay in your live JavaScript until you rebuild

Put a secret in a NEXT_PUBLIC_ variable and Next.js copies its value into the JavaScript it sends to every visitor.

The Next.js docs explain how: at next build, each process.env.NEXT_PUBLIC_ reference is replaced with the hard-coded value, and after the build the app no longer responds to changes in those variables.

So if you spot a Stripe or OpenAI secret under that prefix, renaming it or deleting it in your hosting dashboard does nothing for the site that's already live. The key keeps shipping until you build again.

Fix: revoke and reissue the key first, keep the new one in a server-only variable read in a route handler, then rebuild and redeploy.

Source: https://nextjs.org/docs/app/guides/environment-variables

See whether your live bundle still contains a secret with a free, read-only scan at https://leaklatch.vercel.app