v0 apps, public env vars, and Supabase auth
v0 deploys to Vercel and can connect a backend. Vercel and Supabase document which keys are public and which keys bypass row level security.
By ShipSecurely Editorial · Updated · How we make these guides
Shows up in: Next.js, Vercel, Supabase
What it is
Vercel's v0 docs say you can connect a backend and deploy with one click to Vercel, and that the stack includes Next.js. They do not publish a count of insecure v0 apps. The rules below are the vendor rules that apply when a v0 project uses environment variables or Supabase.
Can I put my Supabase secret key in a v0 public env var?
No.
At next build, Next.js replaces direct process.env.NEXT_PUBLIC_ references in browser-bound code with their values, so those values ship in the JavaScript sent to the browser. Supabase says the secret key bypasses row level security and must never go in a browser. A secret never goes in a NEXT_PUBLIC_ name. Only the project URL and the publishable key belong there, and the publishable key is safe there only with row level security enabled on every table.
# Public: direct references are inlined into browser JavaScript at next build
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=sb_publishable_...
# Server only: no NEXT_PUBLIC_ prefix, read it only in server code
SUPABASE_SECRET_KEY=sb_secret_...
Supabase's Vercel integration installs these three names, among others, and v0 inherits environment variables from the connected Vercel project. The v0 preview window can only access variables from the Development environment. Supabase writes publishable keys as sb_publishable_... and secret keys as sb_secret_.... Next.js loads the JavaScript and CSS files it serves from /_next/ out of .next/static/, the default output folder for those files. After next build on a local copy, search that folder for the literal secret key prefix:
grep -r "sb_secret_" .next/static
Inspect every match, because example text or scanner code that mentions the prefix also matches. No match only shows that the literal string is absent from those files. It does not prove the rest of the app is safe. A legacy service_role key is a JWT with no sb_secret_ prefix, so this search does not find it. Supabase recommends secret keys over that legacy key.
v0's security docs say only NEXT_PUBLIC_ variables are exposed to the browser, and to never expose sensitive tokens with that prefix. The same split in Bolt and Vite projects, and the env option in next.config that also puts a name in the browser bundle, are in Public env vars, the Supabase anon key, and row level security.
Vercel says environment variables are encrypted at rest, Config values stay readable to members with access, and Secret values are write-only after saving.
Auth still has to run on the server. Hiding a link in the React tree does not apply a Supabase policy.
How to check in 5 minutes
In the Vercel project, open Environment Variables. Confirm the Supabase secret key is a Secret, not a Config value, and is not named with
NEXT_PUBLIC_.Search the v0 project for
SERVICE_ROLEandSECRET_KEYinside client components. Supabase says the secret key does not belong in the browser.In the Supabase dashboard, confirm RLS is enabled on tables the browser client queries. Send one signed-out request with the publishable key and confirm you do not receive another user's row.
How to fix
v0
Keep the publishable URL and key in NEXT_PUBLIC_ variables. Move the secret key to a server module that client components do not import. Redeploy after you change Vercel environment variables. Vercel says existing deployments keep their previous values.
Vercel
Set credentials as Secret environment variables. Vercel's docs say you cannot convert a Secret to Config in place. Delete and recreate it if you stored a secret as Config by mistake, and rotate the key that was readable.
Supabase
Enable RLS and policies before you rely on the publishable key. Do not use the secret key from a v0 client component.
Copy the fix prompt
Paste this into Cursor, Lovable, Bolt, or Claude Code. Read the diff before you merge it.
You are checking a v0 project that deploys on Vercel. Do not add features. 1. List env vars. Anything NEXT_PUBLIC_ must be safe to ship in the browser. 2. If Supabase is used, enable RLS and show the policy. Remove the secret key from client code. 3. Do not invent a breach statistic. Show the files you changed.
Questions
Can I put my Supabase secret key in a v0 public env var?
No. At next build, Next.js replaces direct process.env.NEXT_PUBLIC_ references in browser-bound code with their values, and Supabase says the secret key bypasses row level security and must never go in a browser. Put NEXT_PUBLIC_SUPABASE_URL and NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY in public names, and keep SUPABASE_SECRET_KEY without the prefix, in server code only. Enable row level security on every table before you rely on the publishable key. After a build, grep -r "sb_secret_" .next/static is a literal-prefix search of the browser files. Inspect any match, because example text or scanner code can also contain the prefix. No match only shows that literal string is absent from those files. A legacy service_role key has no sb_secret_ prefix, so this search does not find it.
Does the v0 docs page say it scans for RLS?
No. The v0 overview describes prompting, connecting a backend, and deploying to Vercel. v0's security docs say v0 analyzes NEXT_PUBLIC_ usage and warns about potential security risks. Neither page describes a row level security scan. The RLS requirement comes from Supabase's securing-data guide, which applies when the app uses Supabase.
Is the anon key a leak by itself?
Supabase says the publishable key, and the older anon key, can identify the project and are not secrets. They are a leak when RLS is off, because the key can then read and write the rows the policies fail to restrict.
Sources
Related
Guides
Need someone to fix it for you? See /help.
The weekly fix
The weekly fix: 3 real security mistakes in vibe-coded apps and how to fix them, every Tuesday.