PatchPaste · Guides
Last updated 30 October 2026
Is the Supabase anon key safe to expose?
Yes, the anon key is made to be public, but only if Row Level Security (RLS) protects your tables. The service_role key is the opposite. It must never reach the browser. If you built your app with Lovable, Bolt, Cursor or another AI tool, check both, because AI editors sometimes mix them up.
sb_publishable_ key in your frontend is normal. A service_role or sb_secret_ key there is a leak. Your RLS policies, not the key, decide what strangers can see. Or scan your live app free and we'll check from the outside.anon vs service_role: what each key does
| anon / publishable key | service_role / secret key | |
|---|---|---|
| Looks like | sb_publishable_... or a JWT with role anon | sb_secret_... or a JWT with role service_role |
| Made for | Browser and mobile apps | Servers, Edge Functions, scripts |
| Safe in frontend code? | Yes, if RLS is on and your policies are right | Never |
| Follows RLS? | Yes | No, it skips RLS completely |
| If someone copies it | They can do what your policies allow | They can read, change or delete everything |
Supabase says the publishable key is “safe to expose online”, while secret keys give “full access to your project's data, bypassing Row Level Security”. The key only says what is calling, like your web page. Supabase Auth says who is calling. A request with the public key runs as the anon role, or as authenticated once a user signs in (Supabase docs: API keys).
Newer projects show publishable (sb_publishable_...) and secret (sb_secret_...) keys. Supabase is phasing out the older JWT-style anon and service_role keys by the end of 2026. The rule is the same: publishable can be public, secret stays on the server.
Why VITE_ and NEXT_PUBLIC_ values are public
Putting a value in .env does not keep it secret if its name has a public prefix:
- Vite (used by most Lovable and Bolt apps): variables starting with
VITE_“will be exposed in client-side source code after Vite bundling” (Vite docs). - Next.js:
NEXT_PUBLIC_values are “inlined into any JavaScript sent to the browser” (Next.js docs).
So VITE_SUPABASE_ANON_KEY is fine. But VITE_SUPABASE_SERVICE_ROLE_KEY, VITE_OPENAI_API_KEY or NEXT_PUBLIC_STRIPE_SECRET_KEY means the secret goes to every visitor. More on this: are VITE_ variables secret?
Check your live app (2 minutes)
- Open your deployed site in a private window.
- Open dev tools → Sources and search all files (Ctrl/Cmd + Shift + F) for
sb_secret_,service_role,sk_live(Stripe) andsk-(OpenAI and other AI keys). - A legacy key looks like a JWT starting with
eyJ, whether it's anon or service_role. To tell them apart, decode the middle part on your own computer and read therole. Don't paste a key that might be secret into a website. Our service_role guide has a one-line command for this.
If you find a service_role or secret key in the browser
Follow Supabase's order, so the new key doesn't leak the same way:
- Fix the cause first. Move any code that needs the key into a server route or Supabase Edge Function. The browser should only use the publishable or anon key.
- Make a new secret key in Supabase under Settings → API Keys, and put it only in server-side settings.
- Check everything works on the new key.
- Retire the leaked key. Delete a leaked
sb_secret_key (this can't be undone). For a leaked legacyservice_rolekey, turn off the legacy keys in the same place. That also turns off the legacy anon key, so move your frontend to a publishable key first. - Replace any other secret keys (Stripe, OpenAI and so on) you found the same way.
Full steps: Supabase service_role key exposed.
The public key is only as safe as your RLS
Supabase says to turn on RLS for every table and to review your policies for the anon and authenticated roles. Watch for policies like using (true), which let everyone through. See why using (true) makes your data public and how to check your RLS.
Supabase anon key FAQ
Is the Supabase anon key safe to expose?
Yes. The anon key, and the newer sb_publishable_ key, are made to be public. Supabase says the publishable key is safe to put in a web page or mobile app. It only reaches what your Row Level Security policies allow, so it is only safe if RLS is on for every table.
Can someone hack my app just because they can see my anon key?
Not with the key alone. They can do whatever your RLS policies let the anon role do, and after they sign up, whatever the authenticated role can do. If a table has RLS off, or a policy like using (true), they can read that data.
What is the difference between the anon key and the service_role key?
The anon (publishable) key maps to the anon role, and RLS applies to it. The service_role (secret) key maps to the service_role role, which has BYPASSRLS. It skips every policy, so it must never be in browser code.
Should I hide the anon key behind a proxy?
Usually not. Anyone can still call your proxy. Spend that time on correct RLS policies instead, because they are what actually protect your data.
Is the Stripe publishable key (pk_live_) safe too?
Yes. It is made for the browser. The Stripe secret key (sk_live_) is not and must stay on your server.
I removed a secret key from my code. Am I safe?
Not until you replace it. Anyone who loaded your site before could have copied it, and old builds or git history may still have it. Make a new key, move your server code to it, then delete or turn off the old one.
Can PatchPaste tell which Supabase key my site uses?
Yes. PatchPaste loads your live site like any visitor and reads the JavaScript it sends. It flags sb_secret_ keys and JWTs whose role is service_role, shown masked. If it finds a public anon key, it uses it to test a short list of common table names, read-only, at most one row each, and throws the data away.
Check your live app free
Paste your URL. We read the JavaScript your site sends to every visitor and flag Supabase secret and service_role keys (shown masked), plus Stripe, OpenAI and other secret keys. We also test common tables with your public key (read-only, at most one row, never stored), and check for exposed files and missing headers. The report is free. Scans are free, so you can scan again after each AI edit.
Want to see one first? View a sample report.