What does NEXT_PUBLIC_ mean in an environment variable?

Any 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 read 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