Supabase is retiring the anon and service_role keys: what to change in your app before late 2026
If your app uses Supabase, it most likely connects with two long keys that start with eyJ: the anon key in the browser and the service_role key on the server. Supabase's docs say these legacy keys are being deprecated by the end of 2026, replaced by publishable keys (sb_publishable_…) and secret keys (sb_secret_…) (Supabase API keys docs). The exact date isn't set yet: Supabase's announcement says "late 2026, TBC" (Supabase announcement).
Nothing breaks today. But when the legacy keys are deleted, an app that still sends them can't reach its database. This guide shows how to tell in two minutes whether your app uses them, and the switch to make.
The timeline
| When | What changes |
|---|---|
| November 2025 (already in effect) | New projects don't get the anon and service_role keys. A paused project restored since November 1, 2025 comes back without them. Supabase sends monthly reminders. |
| Late 2026 (date to be confirmed) | The legacy keys are deleted. Apps that haven't switched stop working. |
Source: Supabase's announcement and its migration guide, checked November 1, 2026.
Is your app affected?
Go by the key's value, not its name. A legacy key is a long string that starts with eyJ. A new key starts with sb_publishable_ or sb_secret_.
- Lovable: the generated file
src/integrations/supabase/client.tsnames the keySUPABASE_PUBLISHABLE_KEY, but in the public Lovable repos we checked on November 1, 2026, its value was still a legacy anon key starting witheyJ. - Bolt, v0, Replit, Cursor and hand-built apps: look at the environment variables on your host, such as
VITE_SUPABASE_ANON_KEY,NEXT_PUBLIC_SUPABASE_ANON_KEYorSUPABASE_SERVICE_ROLE_KEY. - Edge Functions that read
SUPABASE_ANON_KEYorSUPABASE_SERVICE_ROLE_KEY. - Database webhooks or
pg_netcalls that send the service_role key in anAuthorization: Bearerheader.
Restored a paused project and now every request fails? That's this change already. Since November 1, 2025, a restored project has no legacy keys, so an app that sends an eyJ key is rejected. Steps 1 to 3 below fix it.
Want all three dated checks (Oct 30 grants, Nov 19 model, legacy keys) at once? Run the one free check.
Free check: does your app use the legacy keys?
Paste a public GitHub repo. Your browser reads the code, .env and SQL files through the GitHub API and lists every legacy key, new key and Edge Function that reads a legacy key variable. Keys are never shown, only where they are. Nothing is sent to VibeRescue and nothing is stored.
Step 1: create the new keys
In the Supabase dashboard, open your project's settings and go to API Keys. Create a publishable key and a secret key if they aren't there yet. The legacy keys keep working while you switch.
Step 2: switch the browser side to the publishable key
Replace the anon key with the publishable key wherever the Supabase client is created, or in the environment variable that holds it. It behaves like the anon key: your Row Level Security policies still decide what it can read and write. Prompt for Lovable, Bolt or Cursor:
Replace the legacy Supabase anon key in this app with this publishable
key: KEY. Change only the key value where the Supabase client is created
and in the env files. Don't change anything else. Then list each file
you changed.
Paste the publishable key where it says KEY. Never paste a secret key into a chat. Then publish or redeploy: in Vite apps, VITE_ variables are built into the app, so a new value needs a new build.
Step 3: switch the server side to a secret key
Replace the service_role key with the secret key in your server's environment variables only. A secret key bypasses Row Level Security, like service_role, and Supabase refuses it with a 401 error when it's sent from a browser.
Step 4: update Edge Functions
Inside Edge Functions, the new keys are in SUPABASE_PUBLISHABLE_KEYS and SUPABASE_SECRET_KEYS, which hold JSON keyed by key name. Send a new key in the apikey header. Sent as Authorization: Bearer, it fails with "Invalid JWT", because the new keys aren't JWTs.
const keys = JSON.parse(Deno.env.get('SUPABASE_SECRET_KEYS') ?? '{}')
const secretKey = keys['default']
If a function is called with a new key instead of a user's login token, set verify_jwt = false for it in supabase/config.toml and check who is calling inside the function.
Step 5: update database webhooks
Database webhooks and pg_net calls that used the service_role key should send the secret key in the apikey header. Store the key in Supabase Vault, not in the SQL text.
Step 6: turn off the legacy keys
When nothing uses the eyJ keys anymore, deactivate them in API Keys. You can turn them back on if something breaks, which makes this a safe test before Supabase deletes them. If your service_role key was ever in a public repo, this is also what stops the leaked key from working.
If your app runs on Lovable Cloud rather than a Supabase account of your own, you may not have a Supabase dashboard to do this in. Ask Lovable support how they handle the change before editing keys yourself.
FAQ
When will the Supabase anon and service_role keys stop working?
Supabase's docs say the legacy anon and service_role keys are being deprecated by the end of 2026. Its announcement lists the deletion as late 2026, with the exact date still to be confirmed. Apps that still use them stop working when they are deleted, so switch to the publishable and secret keys before then.
How do I know if my app uses the legacy keys?
Look at the key value, not its name. Legacy keys are long strings that start with eyJ. The new keys start with sb_publishable_ or sb_secret_. Lovable's generated client file names the key SUPABASE_PUBLISHABLE_KEY, but in the Lovable repos we checked the value is still a legacy anon key.
Is the publishable key safe to put in my frontend?
Yes. It replaces the anon key and is meant for the browser. As with the anon key, what it can read and write is controlled by your Row Level Security policies.
Why does my restored Supabase project reject my API key?
Since November 1, 2025, a paused project that is restored no longer gets the legacy anon and service_role keys. An app that still sends a key starting with eyJ is rejected. Create a publishable key and a secret key and switch the app to them.
What if my service_role key is in a public GitHub repo?
Treat it as leaked: it bypasses Row Level Security. Deleting the file doesn't remove it from the git history. Move your server code to a new secret key, then deactivate the legacy keys in the API Keys settings, which also turns off the leaked key.