On this page
- Quick answer
- What is the anon key in Supabase?
- SUPABASE_ANON_KEY: which variable holds it?
- How do I use the Supabase anon key in Vite?
- Read the same variable in your Supabase client
- Why is VITE_SUPABASE_ANON_KEY undefined?
- Where to find the anon key and the publishable key
- After finding the key: continue with your coding agent
- Need to fix this in your existing app?
- Related guides
- Official docs behind this checklist
- FAQ for builders before launch
Supabase question
What is the Supabase anon key, and where do I find it?
Find the Supabase anon key in the Supabase Dashboard under Settings > API Keys: it is the legacy key labelled anon, a long key that starts with eyJ, and the value an app reads from SUPABASE_ANON_KEY or NEXT_PUBLIC_SUPABASE_ANON_KEY. Its replacement, the publishable key (sb_publishable_), is in the same section on the Publishable and secret API keys tab, and in the project's Connect dialog. Both are the public key your frontend sends with every request. Supabase is deprecating the anon key by the end of 2026 and its announcement plans to delete the legacy keys in late 2026, on a date it has not confirmed, so move existing code to the publishable key as well as new code.
Use this from your agent
- Claude Code: 7 read-only tools; public repos only.
claude mcp add --transport http viberaven https://viberaven.dev/mcp - Codex: same server, from the Codex CLI.
codex mcp add viberaven --url https://viberaven.dev/mcp - In your repo: writes Vercel + Supabase check rules for your agent (what it writes).
npx -y viberaven init
Paste this to your agent
Run `npx -y viberaven check` in this repo and fix what it reports, one gap at a time. Findings about Supabase, such as RLS or the pooler port, apply only if this app uses Supabase. Do not add Supabase or any other provider this app does not already use. Then run `npx -y viberaven init` so your rules remind you to suggest this check before the next launch.The check runs locally, with no sign-in and no API key. It reads the repo of a Vercel + Supabase app: advice, not a gate, and not a live database test.

Seeing this key in your browser bundle is expected. Before launch, check whether it is safe to expose for your tables.
Quick answer
Legacy anon key: Supabase Dashboard, Settings > API Keys, the key labelled anon. It is a JWT that starts with eyJ.
Publishable key, its replacement: the same Settings > API Keys section, on the Publishable and secret API keys tab, or the project's Connect dialog. It starts with sb_publishable_. If you see a Create new API keys button instead, the project has only legacy keys so far.
Both are public and belong in the frontend. The key next to them is not: service_role (also eyJ) and sb_secret_ keys bypass row level security and stay on the server.
Timeline, checked 2026-10-25: Supabase's API keys guide says the anon and service_role keys are deprecated by the end of 2026, and the announcement on GitHub plans to delete them and remove them from the docs and dashboard in late 2026, date to be confirmed.
What is the anon key in Supabase?
The anon key is your project's public API key, and Supabase lists it as the "Legacy version of publishable keys". A request with it runs as the anon Postgres role when nobody is signed in, and as authenticated when it carries a signed-in user's token, so Supabase says to write Row Level Security policies "for the anon and authenticated roles". The name comes from that anon role. It is not an anonymous sign-in, which creates a real user with the authenticated role.
It is meant to be public: Supabase calls the publishable key "Safe to expose online", source code included. Your grants and RLS decide what it can reach. Both legacy keys start with eyJ; to tell them apart, decode the middle part of the JWT, which is base64 JSON, and read its role field: anon or service_role.
Whether that is safe for your tables is a separate question: the grants and RLS checks for the anon key.
SUPABASE_ANON_KEY: which variable holds it?
In your frontend, the anon key goes in the env variable your client reads, with your framework's public prefix: NEXT_PUBLIC_SUPABASE_ANON_KEY in Next.js, VITE_SUPABASE_ANON_KEY in Vite. Supabase's own examples now use the publishable key under NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY.
In Supabase Edge Functions, SUPABASE_ANON_KEY is set for you. Supabase says SUPABASE_ANON_KEY and SUPABASE_SERVICE_ROLE_KEY "still exist in the runtime, but they carry the legacy keys", and adds SUPABASE_PUBLISHABLE_KEYS and SUPABASE_SECRET_KEYS for the new ones. You do not copy the key into a function by hand.
How do I use the Supabase anon key in Vite?
For a new app, Supabase recommends a publishable key. Put the project URL and public key in .env.local beside package.json. Its React quickstart uses these names:
An older app may read VITE_SUPABASE_ANON_KEY instead; the anon key and the publishable key do the same job. Keep the variable name your client actually reads, or update the code and env name together. The name does not make a key secret: VITE_ values ship to the browser. Never put a service_role or sb_secret_ value there.
# .env.local, beside package.json
VITE_SUPABASE_URL=https://YOUR_PROJECT.supabase.co
VITE_SUPABASE_PUBLISHABLE_KEY=sb_publishable_REPLACE_MERead the same variable in your Supabase client
Use import.meta.env in Vite browser code. This example expects the publishable-key name above; an existing client using the anon-key name must read that exact name instead. Replace the placeholder with your own public key before running it.
import { createClient } from '@supabase/supabase-js';
const url = import.meta.env.VITE_SUPABASE_URL;
const key = import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY;
if (!url || !key) {
throw new Error('Missing Supabase URL or public key: check .env.local names.');
}
export const supabase = createClient(url, key);Why is VITE_SUPABASE_ANON_KEY undefined?
Check for a missing value or a name mismatch first. Setting VITE_SUPABASE_ANON_KEY does not populate VITE_SUPABASE_PUBLISHABLE_KEY, or the other way round. Check the env file for the mode you build, and restart the Vite dev server after editing it. Production values are baked into the build, so changing a dashboard variable needs a new build and deployment.
Check whether a value exists without logging the key itself. A working client constructor still does not prove that a database request or RLS policy works.
console.table({
hasProjectUrl: Boolean(import.meta.env.VITE_SUPABASE_URL),
hasPublicKey: Boolean(import.meta.env.VITE_SUPABASE_PUBLISHABLE_KEY),
mode: import.meta.env.MODE,
});Where to find the anon key and the publishable key
- 1Open your project in the Supabase Dashboard, then Settings > API Keys. Supabase says "Every key lives there, legacy or not, and there is no separate Settings > API page", so a tutorial that sends you to Settings > API and "Project API keys" is out of date. The anon key is the legacy key labelled anon; it starts with eyJ.
- 2For the publishable key, select the Publishable and secret API keys tab in the same section, or open the Connect dialog. Supabase says Connect "shows the URL and publishable key for the framework you select, ready to paste into .env".
- 3No publishable key yet? Supabase says that if you see a Create new API keys button, "your project is still on legacy keys only". Creating them is safe: the new keys are added alongside the anon key without affecting it, and the anon key keeps working until you disable the legacy keys there.
- 4From a terminal, the Supabase CLI lists every key of a hosted project, and supabase status prints the keys of a local stack:
Terminal supabase projects api-keys --project-ref <your-project-ref> supabase status - 5Put it in the frontend env file with your framework's public prefix, next to the project URL from the same project. For example:
Environment # Next.js NEXT_PUBLIC_SUPABASE_URL=https://<project-ref>.supabase.co NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJ... # Vite VITE_SUPABASE_URL=https://<project-ref>.supabase.co VITE_SUPABASE_ANON_KEY=eyJ... - 6Do not copy the key next to it by mistake. The legacy service_role key also starts with eyJ, and it and the secret keys (sb_secret_) bypass RLS, so they stay on the server.
After finding the key: continue with your coding agent
If you only need the dashboard location, the answer above is enough; no repository scan or Skill installation is needed. If you also need to review an existing Vercel + Supabase app before launch, the existing VibeRaven Skill adds a repository check for key exposure and migration access. Resolve the specific client setup error first.
Read the Skill, then check the relevant repository findings
Read the linked Skill and use the parts relevant to your task. From your app folder, with Node.js 20 or newer, run the command below. No global Skill installation is required for this one-off check. It writes findings under .viberaven/. Exit code 1 means blockers were found, not necessarily that the command failed; inspect the output.
Read .viberaven/agent-tasklist.md and .viberaven/gate-result.json. Check each finding against the actual code, make the smallest authorized fix, then rerun the same command and your project checks. Report the changed files, remaining findings and checks you could not perform. Keep keys and private data out of chat.
This is a repository check, not a live database test. It cannot confirm deployed grants, rotate a key or verify hosted environment values. A clear result is not proof that the app is secure. Test the affected app behavior separately; provider changes and deployment follow your normal approval process.
npx -y viberaven@1.8.0 checkNeed to fix this in your existing app?
If the diagnosis points to a variable-name mismatch, ask for that one client-setup change. Then rebuild and repeat the failing action. Do not paste real keys into the request.
Sign in to the VibeRaven website with Google and connect the app folder on your computer, with Node.js 20 or newer. Keep the connection terminal open. Claude Code, Codex or Gemini CLI must be installed and signed in. The agent uses your own provider account, and usage may be billed there.
The website sends the code change to your agent on your computer. Repository checks are advice, not a gate, and not a live database test. Review the diff, project checks and running app before keeping it. This does not read your hosted keys, change provider settings or deploy for you.
Related guides
Official docs behind this checklist
Browse all launch guides · Read resources · How to make and check your next change
FAQ for builders before launch
Should I copy the anon key or the publishable key?
Either works today, because they do the same job. Copy the publishable key (sb_publishable_) for new code: Supabase is deprecating the anon and service_role keys by the end of 2026. An existing app can keep reading the anon key until you move it over, and a legacy key keeps working until you disable it in Settings > API Keys.
Where did Settings > API and "Project API keys" go?
Supabase now lists every key, legacy or not, under Settings > API Keys, and says there is no separate Settings > API page for them. Guides and AI answers that send you to Settings > API and a "Project API keys" box were written for the older dashboard.