What does NEXT_PUBLIC_ mean in an environment variable?

Published 2026-11-16 by Nordik. Written with AI from the sources listed at the end.

Short answerAny setting named with NEXT_PUBLIC_ is copied into the code every visitor downloads, so it must never hold a secret.

An environment variable is one named setting, where an app keeps things like its keys (long passwords it uses to prove who it is to another service). The Next.js documentation says variables are server-only by default. A name starting with NEXT_PUBLIC_ tells Next.js to inline the value into the JavaScript sent to the browser at build time. The browser is the program people use to open websites, such as Chrome or Safari.

So NEXT_PUBLIC_SUPABASE_URL is fine, and a secret key named NEXT_PUBLIC_anything is exposed to every visitor. Because the value is baked in at build time, changing it later needs a new build and deploy (putting the app online again).

A quick check: list your variable names and look for any that start with NEXT_PUBLIC_ and hold a secret. Rename it, move the call to server-side code, replace the key (make a new one and turn the old one off), and put the app online again so the new build no longer contains it.

Sources

Each source below was accessed on 2026-11-16. Documentation changes over time, so check the source for the current wording.

  • Next.js documentation, Environment variables, accessed 2026-11-16

See what your live app shows strangers

Paste the link to your app: in under a minute the free scan shows what your live app hands to any visitor, and where to look first. No sign-up, and it never signs in or changes anything.

Run a free scan

Want the code itself read? Order the $49 audit or see a sample report. Your card is held and charged only when your report is delivered. It is not a pentest: the audit is done by AI, and a second AI checks each serious finding.