Supabase is retiring anon and service_role keys: what to change
Supabase is replacing anon and service_role keys with sb_publishable_ and sb_secret_. What to change, which header to use, and what to rotate.
Check your live site
Run the free ShipLatch scan on your own site without leaving this page.
Uses 1 of your 3 free scans today; a site scanned in the last 24 hours answers from that scan. Passive and read-only: we only look at what any browser can see. Only check sites you own or may test.
What the free scan checks
- Leaked keys in your live JavaScript (AI, payment and cloud keys), including a Supabase
service_rolekey - Files that should never be public, like
/.envand/.git - Supabase and Firebase secrets in the browser: an
sb_secret_key, a Supabase access token or a Firebase service-account file - HTTPS and security headers (CSP, HSTS, clickjacking protection)
It only reads what any visitor's browser can see. It doesn't log in, read your tables or check App Check.
Related free check: Is your Supabase app exposing more than it should?
The short version
Supabase is replacing its two old keys with two new ones:
| Old key | New key | Safe in your app's frontend? |
|---|---|---|
anon (a long eyJ... token) |
sb_publishable_... |
Yes |
service_role (also eyJ...) |
sb_secret_... |
Never |
Supabase says it is deprecating anon and service_role "by the end of 2026" (Supabase API keys docs). New projects stopped getting the legacy keys in November 2025 (Supabase GitHub announcement).
Why it matters to you
- A secret key (
sb_secret_orservice_role) skips every Row Level Security policy. By design it has "full access to your project's data" through the API, so treat a leaked key as a full data exposure (docs). - A publishable key is fine to ship in your app. However, your data is only as safe as your RLS policies.
- Creating new keys does not turn off your old ones. Both keep working until you disable the old ones under Settings → API Keys (docs).
Step by step
- In the Supabase dashboard, open Settings → API Keys. If you see Create new API keys, click it. This is safe; your old keys keep working (migration guide).
- Frontend (Lovable, Bolt, v0 and so on): replace the anon key with the
sb_publishable_...key. It usually lives inVITE_SUPABASE_ANON_KEY/VITE_SUPABASE_PUBLISHABLE_KEYorNEXT_PUBLIC_.... - Backend only (Edge Functions, API routes): use
sb_secret_.... Edge Functions get it asSUPABASE_SECRET_KEYS(migration guide). - If you call Supabase with your own
fetch, send the new keys in theapikeyheader only. If you also put the key inAuthorization: Bearer, Supabase rejects the request with "Invalid JWT" (migration guide). - Check the "last used" indicators in the dashboard. Once nothing uses the old keys, disable them (JWT signing keys docs).
- If a secret or
service_rolekey was ever in your frontend code, treat it as leaked and rotate it now.
A related change
Since 8 April 2026, Supabase no longer returns your database's API schema to anon-key requests (Supabase changelog). This is good for you because attackers can no longer list your tables that way. It does not replace RLS: anyone who guesses a table name can still query it.
Quick self-check
Search your live site's JavaScript for sb_secret_ and service_role. If either one shows up, rotate the key today.
Scan your app free
ShipLatch checks your live site for leaked keys, public env values, source maps and exposed files. The $29 Fix Pack gives you fix prompts written for your app and re-scans that prove each fix worked.
Want the whole pre-launch process in one place? See what's inside App Security for Vibe Coders, our $9 PDF playbook, or go straight to checkout.