Terms & acceptable use
🔑 Free Supabase key check

Not sure if your live app ships a service_role or sb_secret_ key, or if your anon key leaves tables open? Paste your URL and check your live app in 10 seconds. Free.

FreeJust your email to see results10 seconds

The free scan shows your problems. The $9 fix report gives you a copy‑paste fix prompt for each one.

Guide · Supabase API keys · Updated

Supabase anon Key vs service_role Key: Which Key Is Safe in the Browser?

Every Supabase project gives you two kinds of keys: a public key for your frontend (sb_publishable_... or the legacy anon key) and a master key for your server (sb_secret_... or the legacy service_role key). Mixing them up is one of the fastest ways to expose every row in your database. Here is what the official Supabase docs say, why AI builders mix them up, and how to check your live app in 60 seconds.

1. anon (publishable) vs service_role (secret) at a glance

Supabase docs compare your project to a building: the publishable key is taped to the front door and only opens what your rules allow, while the secret key is the master key that stays in your pocket.

Key typeWhat it looks likePostgres roleRow Level Security (RLS)Where it belongs
Publishable keysb_publishable_...anon (signed out) or authenticated (signed in)FollowedBrowser, mobile app, desktop app, CLI
Legacy anon keyeyJ... (JWT with role: "anon")anon (signed out) or authenticated (signed in)FollowedBrowser, mobile app (legacy; migrating to sb_publishable_)
Secret keysb_secret_...service_role (has BYPASSRLS)Bypassed completelyServer routes, Edge Functions, cron jobs. NEVER in browser
Legacy service_role keyeyJ... (JWT with role: "service_role")service_role (has BYPASSRLS)Bypassed completelyServer only. NEVER in browser (legacy; migrating to sb_secret_)

Supabase is deprecating the legacy JWT-based anon and service_role keys (long strings starting with eyJ) by the end of 2026 in favor of short sb_publishable_... and sb_secret_... keys. Both pairs work the same way with Postgres roles and Row Level Security.

Source: Supabase: API keys

2. When the anon / publishable key is safe (and when it is not)

People often panic when they see their anon or sb_publishable_ key in Chrome DevTools. Seeing that key in the browser is normal. Every browser Supabase app ships it.

When your app uses the publishable or anon key:

  • If the visitor is not signed in, Postgres runs the request as the anon role.
  • If the visitor is signed in through Supabase Auth, your app still sends the publishable key as the apikey header, plus the user's Auth token, and Postgres runs the request as the authenticated role.

Here is the catch: the anon key is safe in browser code only when Row Level Security (RLS) is enabled on every table in public (with policies that check who the user is). Supabase's RLS docs warn that a table in an exposed schema without RLS is readable and writable by any role that has a table grant on it. On projects where tables in public grant select, insert, update and delete to anon, turning RLS off means anyone with your anon key can read, edit or delete the whole table.

Want to test what your public key can read right now? Follow our Supabase RLS check.

Sources: Supabase: API keys · Supabase: Row Level Security

3. Why service_role and sb_secret_ must never touch the frontend

Both the legacy service_role key and the newer sb_secret_... key map to the built-in service_role Postgres role. By design, that role has the BYPASSRLS attribute: it bypasses every Row Level Security policy completely.

  • Never put it in NEXT_PUBLIC_, VITE_ or EXPO_PUBLIC_. Those prefixes tell Next.js, Vite and Expo to inline the key into the public JavaScript bundle sent to every visitor. See which env vars end up in the browser.
  • Browser block on sb_secret_ does not make a leak safe. Supabase blocks sb_secret_... requests that come directly from a browser by checking the User-Agent header and returning HTTP 401 Unauthorized. But Supabase docs warn that if sb_secret_ is bundled into your frontend code, an attacker can still copy the string and run it from curl, Postman or their own script, where no browser User-Agent stops it.
  • Legacy service_role JWTs work right in the browser. Unlike sb_secret_, the older eyJ... service_role JWT does not fail in a browser, so an app using it in client code looks like it works while giving every visitor admin access.

Sources: Supabase: API keys · Supabase: Bypassing Row Level Security

4. Why vibe-coded apps accidentally leak service_role

When you build with Lovable, Bolt, v0, Replit or Cursor, you rarely paste service_role into the frontend on purpose. It usually happens during debugging:

  1. You hit permission denied for table (42501) or get an empty [] back. Either the table is missing a GRANT (especially after Supabase's October 30, 2026 default grants change) or RLS is on without a matching policy.
  2. You tell the AI: "My query is failing, just make it work."
  3. The AI swaps in SUPABASE_SERVICE_ROLE_KEY. To make the error disappear immediately, the AI initializes createClient() with the service_role key and renames the variable to NEXT_PUBLIC_SUPABASE_SERVICE_ROLE_KEY or VITE_SUPABASE_SERVICE_ROLE_KEY so the browser can read it.

The error disappears, the UI loads your data, and every visitor now has a master key to your database. The safe fix for 42501 or [] is always a proper GRANT plus an RLS policy for authenticated (or moving true admin work to a server route or Edge Function).

5. How to check your live app in 60 seconds + rotate a leaked key

Only check apps you own or have permission to test.

Check your live app in 60 seconds

  1. Fastest: paste your live link above. VibeCheck fetches your live app's public JavaScript bundles, checks if any sb_secret_ or service_role JWT is exposed, and tests if your public key can read open tables.
  2. Manual check in Chrome DevTools: open your live site, right-click → Inspect, and press Ctrl+Shift+F (Cmd+Option+F on Mac) to search all loaded files. Search for sb_secret_ and service_role.
  3. Check eyJ JWT keys: both legacy anon and service_role keys start with eyJ. Look at the middle section of the token (between the two dots) or compare the string against Settings → API Keys in your Supabase Dashboard. In base64, "role":"service_role" encodes to InJvbGUiOiJzZXJ2aWNlX3JvbGUi. If that string is in your browser bundle, your service_role key is public.

How to rotate a leaked Supabase secret or service_role key

Supabase's official rotation steps say not to rush. Fix the code leak first so your new key does not leak on the next deploy:

  1. Remove the secret key from client code and switch the browser client back to sb_publishable_... (or anon).
  2. Open Settings → API Keys in your Supabase Dashboard and create a new secret key (sb_secret_...).
  3. Update every server, worker or Edge Function to use the new secret key (without any NEXT_PUBLIC_, VITE_ or EXPO_PUBLIC_ prefix) and redeploy.
  4. Retire the leaked key: in Settings → API Keys, delete the leaked sb_secret_ key (permanent), or deactivate your legacy JWT keys if the old service_role JWT leaked.

Also leaked an OpenAI or Stripe key? Read I leaked my API key. What do I do now?

Source: Supabase: Rotate a leaked or compromised key

6. Copy-paste fix prompts

Paste the matching prompt into Lovable, Bolt, v0, Replit or Cursor. After you deploy, rotate any service_role or sb_secret_ key that was ever in client code.

Any builder: replace service_role in frontend with publishable/anon key + RLS
Search this project for service_role, SUPABASE_SERVICE_ROLE_KEY, SUPABASE_SECRET_KEY and sb_secret_. Remove every secret or service_role key from client-side code and from any NEXT_PUBLIC_, VITE_ or EXPO_PUBLIC_ variable. In the browser client, use only the Supabase publishable (or anon) key. For any query that broke when you switched back to the public key, keep Row Level Security enabled, grant only the needed privileges to authenticated (or anon if truly public), and write a policy using (select auth.uid()) = user_id. List every key you removed so I can rotate it in Supabase.
Next.js / v0 / Cursor: move admin Supabase calls to the server
Find every place this app needs admin database access that skips Row Level Security. Move those calls into a server-only Route Handler, Server Action or Supabase Edge Function that reads SUPABASE_SECRET_KEY (no NEXT_PUBLIC_ prefix). Inside each server route, verify the signed-in user before running the query. Never return the secret key to the client.
Lovable / Bolt / Replit: fix 42501 or empty [] without service_role
My Supabase queries return error 42501 (permission denied) or an empty array []. Do NOT use the service_role key in the frontend and do NOT disable Row Level Security. Instead, write a SQL migration that keeps RLS enabled on each table, grants the needed select/insert/update/delete privileges to authenticated, and adds separate select, insert, update and delete policies matching rows to (select auth.uid()). Show me the SQL.

7. Check it for me

Want to check your live app right now? Paste your link into VibeCheck. In about 10 seconds it checks the JavaScript your live site sends to visitors for leaked keys (including Supabase service_role and sb_secret_ keys, OpenAI, Anthropic and Stripe secret keys), checks whether your public Supabase key can read open tables without RLS, and checks security headers, SEO basics and broken links.

It is a public, read-only check. It never asks for your source code or login, and it masks any secret key it finds.

Pricing: the problems list is free (just add your email). The $9 fix report gives you a copy-paste fix prompt for every problem found, or get the $29 10-pack (10 fix reports to use any time). No subscription.

No tool can promise your app is 100% secure. VibeCheck catches common, costly mistakes before a stranger does.

8. FAQ

Is the Supabase anon key safe to expose in the browser?

Yes, as long as Row Level Security (RLS) is turned on for every table in your public schema and your policies are tight. Supabase designed the anon key (and the newer sb_publishable_ key) to sit in browsers and mobile apps. Without RLS, though, anyone with that public key can read and change your tables.

What is the difference between the Supabase anon key and the service_role key?

The anon key (or sb_publishable_ key) is a low-privilege public key that follows your Row Level Security rules. It runs as the anon Postgres role when a visitor is signed out, and as the authenticated role when a user signs in. The service_role key (or sb_secret_ key) is a master key for servers only. Its Postgres role has the BYPASSRLS attribute, so it skips every RLS policy.

What are sb_publishable_ and sb_secret_ keys in Supabase?

They are Supabase's newer API keys that replace the legacy JWT-based anon and service_role keys (which Supabase is deprecating by the end of 2026). sb_publishable_... is the public key for client code. sb_secret_... is the secret key for servers and Edge Functions.

What happens if my Supabase service_role or secret key is in my frontend?

Anyone who opens your site can copy it from the JavaScript bundle and get full read, write and delete access to your database, skipping all Row Level Security policies. Even though newer sb_secret_ keys return HTTP 401 when sent directly from a browser User-Agent, anyone who copies the key from your frontend code can still use it from curl or a script.

Why did my AI builder put SUPABASE_SERVICE_ROLE_KEY in my client code?

When a query fails with permission denied (error 42501) or returns an empty list [] because of missing grants or RLS policies, AI builders like Lovable, Bolt, v0, Replit and Cursor sometimes swap in the service_role key to make the query work right away. The right fix is to keep the publishable/anon key in the browser and add the needed table GRANT and RLS policy.

How do I rotate a leaked Supabase service_role or secret key?

First move the secret key out of your client code so the new key does not leak the same way. Then open Settings > API Keys in the Supabase Dashboard, create a new secret key (sb_secret_), update your backend servers to use it, and delete the old secret key (or deactivate the legacy service_role JWT key).

More questions? See the VibeCheck FAQ. Related guides: Supabase RLS check · Supabase error 42501 / Oct 30 change · Is my Lovable app safe? · Is NEXT_PUBLIC_ safe for API keys? · I leaked my API key. What do I do now? · How to check if your API key is exposed · Vibe coding security checklist.