Direct answer
Supabase is deprecating the legacy JWT-based anon and service_role keys by the end of 2026. Publishable keys (sb_publishable_…) replace anon in anything you ship, and secret keys (sb_secret_…) replace service_role on servers only. Both systems work side by side until you deactivate the legacy keys, so you can migrate one caller at a time: inventory every key, swap clients, swap servers, update Edge Functions and webhooks, confirm nothing uses the old keys, then turn them off.
What is changing, and when
Supabase’s API keys guide, updated November 2, 2026, says the anon and service_role keys are being deprecated by the end of 2026. The original announcement on GitHub set out the timetable: legacy keys would be deleted and removed from the docs and dashboard in “Late 2026, TBC”, and apps still using them would break. The same timetable said that from November 2025, projects restored from a pause and newly created projects would no longer get legacy keys. The announcement gives the reasons: the old keys were tied to the project’s JWT secret, could not be rotated independently without downtime, and were JWTs with a 10-year expiry.
The new keys map onto the same Postgres roles. A publishable key acts as the anon role, or as authenticated once a user signs in through Supabase Auth, so your Row Level Security policies behave the same. A secret key acts as service_role, which bypasses Row Level Security entirely. Two differences matter in practice. The new keys are short strings, not JWTs, so a long key starting with eyJ is a legacy key. And a secret key used from a browser is rejected with HTTP 401, based on the User-Agent header.
What AI-built apps commonly get wrong
When we review apps generated with Lovable, Bolt or v0, the key problems tend to be the same few:
- The key is pasted as a literal into client source instead of read from an environment variable. A publishable key is safe to expose, but a literal means every rotation is a code change, and copies end up in old builds and forks.
- The service_role key is in browser code, usually added because a query returned nothing and the elevated key “fixed” it. That hands every visitor full access to the database. The real fix is a policy, as in our guide to the Supabase empty array RLS problem.
- A key is written into Edge Function code or into SQL for a database webhook, where it sits in plain text in the repository or the database.
- Generated code follows older tutorials and copies an
eyJkey into the app, which keeps new projects on the deprecated path.
The migration will surface the second problem whether you look for it or not: a secret key in the browser stops working. Treat that as the moment to move the privileged work to a server.
Migration checklist
- Inventory every key. Frontend env files, server env, Edge Function secrets, Database Webhooks and
pg_netcalls, CI pipelines, third-party integrations, and mobile builds already on users’ phones. Supabase’s migration guide notes there is no automatic usage indicator, so this check is manual. - Create the new keys. In Settings > API Keys. Creating them does not revoke the legacy keys, which keep working.
- Swap the publishable key into clients. Read it from a public environment variable. Server-only variable names should never carry your framework’s public prefix, or the bundler ships the key.
- Put secret keys on servers only. Use a separate secret key per backend component so one leak forces one rotation.
- Update Edge Functions. Read keys from
SUPABASE_SECRET_KEYSorSUPABASE_PUBLISHABLE_KEYS, which are JSON objects keyed by name, or adopt the@supabase/serverSDK, which Supabase recommends. Send the new keys on theapikeyheader. Sent asAuthorization: Bearer, they fail with “Invalid JWT”. Setverify_jwt = falsefor these functions and authorize in code, because the platform’sverify_jwtcheck alone does not authenticate a caller that sends only an API key. - Fix webhooks and pg_net calls. Move the key from the Authorization header to
apikey, and store it in Vault instead of hard-coding it in SQL. - Rotate anything that leaked. If a service_role key was ever in a bundle, a repository or a chat log, rotate it once the cause is fixed. Our note on AI API key security covers why keys belong in a secrets store.
- Deactivate the legacy keys. Supabase says this step is reversible if you find a caller you missed.
Limits to plan for
The migration guide lists a few behaviors that differ from the legacy keys. Public Realtime connections without a signed-in user last at most 24 hours. Anything that tries to verify an API key as a JWT will fail. And the access tokens Supabase Auth issues to users are still signed with the project’s shared JWT secret; moving to JWT signing keys is a separate migration that Supabase suggests doing next.
After you deploy, search the built bundle for eyJ and sb_secret_. Neither should appear in anything that reaches a browser or phone.
Related Zenveus services: Supabase Security Audit, the free Row-Level Security Auditor and Secret Scanner