If your app talks to Supabase with a long key that starts with eyJ, it's on the legacy anon or service_role keys, and Supabase says those are going away. The swap takes about 10 minutes. The risky part is the one an AI tool can get wrong: where the new secret key ends up.
Supabase's API keys docs say it "is deprecating the anon and service_role keys by the end of 2026". The replacements are a publishable key (sb_publishable_...) for browsers and apps, and secret keys (sb_secret_...) for servers. The docs add: "If a tool, tutorial, or AI assistant tells you to copy a long key that begins with eyJ, it was written for the legacy keys."
The timeline on GitHub has two dates that matter:
That usually means the project's legacy keys are switched off (or it was restored from a pause without them), while something still sends an eyJ key. The usual suspects are a cron job, a nightly import or a server script, rather than the main app. Do steps 2–4 for that caller. If you just need things working again while you migrate, re-activate the legacy keys in Settings → API Keys: Supabase says deactivation is reversible.
# in your project (Lovable: sync to GitHub first)
grep -rn "eyJ" src/ .env* 2>/dev/null | grep -iv test
grep -rn "VITE_SUPABASE_ANON_KEY\|NEXT_PUBLIC_SUPABASE_ANON_KEY" . --include=*.env* --include=*.ts --include=*.tsx 2>/dev/null
Also check the live site: open DevTools, search the loaded JavaScript (Ctrl+Shift+F / Cmd+Option+F) for eyJ. Newer Lovable projects already use VITE_SUPABASE_PUBLISHABLE_KEY; older ones use VITE_SUPABASE_ANON_KEY.
In the Supabase dashboard: Settings → API Keys → "Publishable and secret API keys". If you see "Create new API keys", your project is still on legacy keys only. Per the migration guide, creating them is safe: the legacy keys keep working alongside them until you turn them off.
# .env (use the exact variable name your code reads)
VITE_SUPABASE_PUBLISHABLE_KEY=sb_publishable_...
VITE_ and NEXT_PUBLIC_ values are baked in when the app is built, so changing the variable does nothing until you rebuild and republish. Supabase says the publishable key has the same low privileges as anon, so your Row Level Security policies behave the same.
The secret key replaces service_role and, like it, bypasses Row Level Security. It belongs only in servers and Edge Functions (Supabase adds SUPABASE_SECRET_KEYS to the functions' environment). The mistake to watch for: an AI tool "fixing" a permission error by putting sb_secret_... in a VITE_ or NEXT_PUBLIC_ variable.
Supabase's docs say secret keys return HTTP 401 when used from a browser, matched on the User-Agent header. That blocks browsers, not scripts: the key is still in your public bundle for anyone to copy. Check the build:
npm run build
grep -rlE "sb_secret_|service_role" dist/ .next/static/ build/ 2>/dev/null
Any hit: move that call into an Edge Function or server route, then rotate the key in the dashboard. Deleting the line isn't enough; it's still in git history and old deploys.
Supabase's migration guide says there's no automatic usage indicator (its signing keys FAQ mentions "last used" indicators on the API Keys page, so look there too, but don't rely on it alone). Check every place that holds a key, including CI/CD and deploy scripts, webhooks and third-party integrations, cron jobs, workers and pg_net calls, and mobile builds already in users' hands. Deactivating the legacy keys in Settings → API Keys is reversible if you missed one.
Swapping keys changes nothing about who can read what. If a table was readable with the anon key, it's readable with the publishable key too. While you're in there, run the 5-minute anon-key check and the second-user test.
The free Ship-Ready quick scan runs offline on your code and flags service or secret keys in public env vars, RLS turned off and using (true) policies. The Crew (59-check scan, $39) adds more checks and a two-user test template.
Related: is my anon key a problem? · 42501 permission denied after the Oct 30 change · test your app as a second user