Home / Guides / Are VITE_ and NEXT_PUBLIC_ env variables public? Yes.

Are VITE_ and NEXT_PUBLIC_ env variables public? Yes.

Any env var prefixed VITE_, NEXT_PUBLIC_, or REACT_APP_ is compiled into your JavaScript bundle. What belongs there and what doesn't.

Short answer: yes. Build tools replace import.meta.env.VITE_* (Vite), process.env.NEXT_PUBLIC_* (Next.js) and process.env.REACT_APP_* (Create React App) with their literal values at build time. The value ends up in the JS file every visitor downloads. The prefix exists precisely to mark a variable as safe to expose.

Fine to expose

Never prefix these

How to check your live site

Open DevTools → Sources (or Network → JS files) and search for sk-, sk_live, service_role, postgres://. Anything found is public already: move the call to a server route or edge function, then rotate the key. Removing it from the code does not un-leak it.

Copy-paste into your AI builder
List every environment variable this app reads. For each one with a VITE_, NEXT_PUBLIC_ or REACT_APP_ prefix, tell me whether it is safe to be public. Move any secret ones into a server route or edge function, call that from the frontend instead, and tell me which keys I must rotate.

Related: Hide API keys · Leaked OpenAI key

Scan your app free

Paste your URL. ShipLatch checks for leaked keys, exposed /.env and /.git, and flags Supabase/Firebase so you know what to lock down. The free scan finds the issues; the $29 Fix Pack gives you fix prompts written for your app and re-scans that prove each fix worked.

Scan free at shiplatch.com → See the Fix Pack · $9 playbook

Update (Oct 2026): EXPO_PUBLIC_ works the same way, and ShipLatch now flags secret-looking values in any public env var. Read the update →

Want the whole pre-launch process in one place? Get App Security for Vibe Coders, our $9 PDF playbook.

More guides