Guides / NEXT_PUBLIC_ secret exposed
v0 / Next.js apps: NEXT_PUBLIC_ variables are public
In Next.js apps built with v0, any NEXT_PUBLIC_ variable is shipped to the browser. How to check for leaked secrets and fix it.
What it is
v0 generates Next.js apps. In Next.js, environment variables are server-only by default. Anything prefixed with NEXT_PUBLIC_ is inlined into the JavaScript sent to the browser at build time. If a secret key gets that prefix, it is public. Keep secrets un-prefixed and use them only in server code (Route Handlers, Server Actions, Server Components).
How to check
- List every
NEXT_PUBLIC_variable in your Vercel project settings and.envfiles. - Any secret (OpenAI, Stripe secret, database URL, Supabase secret key) with that prefix is exposed.
- Search the live site’s JS bundles for the key values, or run a free Cobalt Owl scan.
Fix it with one prompt
Paste this into Lovable, Bolt, Cursor, v0, Replit or Claude Code:
Check my Next.js app for secrets in NEXT_PUBLIC_ environment variables. Rename every secret so it has no NEXT_PUBLIC_ prefix, use it only in server code (Route Handlers, Server Actions or Server Components), and make the client call those server routes instead. Update the variables in Vercel. Then list the keys I need to rotate because they were exposed.
Review what the AI changes before you publish. If a key was exposed, rotate it even after the fix: anyone may already have a copy.
Check your live app in a minute
Free, read-only scan from the outside. No login, no code access. You must own the app or be allowed to test it.
Check my app freeSources
Last reviewed October 25, 2026. Cobalt Owl is an independent tool and is not affiliated with the builders or providers named here.