Deutsch
Security wikiSupabase · Keys

What is the Supabase anon key (publishable key)?

Also known as: publishable key, sb_publishable_, Supabase anon key, public API key

The Supabase anon or publishable key is the public key your frontend ships with. Why it is not a secret, what it can reach, and how to check that.

By Tim GeithnerPublished 2 min read

Short answer

The anon key, now called the publishable key (sb_publishable_…), is the public Supabase key that your browser code uses to reach the Data API. It is meant to be visible and is not a secret. What it can reach is decided by your grants and row level security policies, so an exposed anon key is only a problem when a table is open.

Ask an AI about this page:ChatGPTClaude

On this page

The anon key, now called the publishable key (sb_publishable_…), is the public Supabase API key that your frontend uses to talk to your project. It identifies the project and lets the browser call the Data API as the anon role; once a user signs in, their session token makes the same requests run as authenticated. Supabase describes it as safe to expose, but adds that it does not protect your data by itself: that is the job of row level security and grants.

The anon key in an AI-built app

When Lovable or Bolt connects a project to Supabase, the generated client file contains the project URL and the anon or publishable key, often through an environment variable such as VITE_SUPABASE_PUBLISHABLE_KEY. Vite bundles that value into the JavaScript every visitor downloads. Copying it from the browser’s developer tools takes seconds, and that is expected.

The risk starts when a table is reachable by anon and has no RLS. Then the copied key reads, and possibly changes, every row, without an account. Security scanners often flag the key itself as “exposed”. The key is not the bug; the open table is.

There are two kinds of keys, and mixing them up is the real mistake:

KeyFormatPostgres roleBelongs in
Publishable / legacy anonsb_publishable_… / JWT eyJ…anon, or authenticated with a user sessionBrowser, mobile app
Secret / legacy service_rolesb_secret_… / JWT eyJ…service_role (bypasses RLS)Server only

Both legacy keys look alike because both are JWTs. If you are not sure which one your frontend uses, see service role key.

How to check your app

Check what the key can reach, not whether it is visible. In the Supabase SQL Editor, pretend to be a visitor inside a transaction that is rolled back:

What a visitor with the anon key sees
begin;
set local role anon;
select count(*) from public.profiles;
rollback;

Replace profiles with each of your tables. A count above zero means anyone with your public key can read those rows. permission denied or a count of zero is what you want for private data. The Security Advisor (lint 0013) lists tables in the public schema without RLS in one go.

How to fix or prevent it

  • Keep using the publishable key in the browser. Never swap it for the secret key to “make a query work”.
  • Enable RLS on every table in the public schema and write policies for anon and authenticated. The Supabase row level security guide walks through it.
  • Revoke grants from anon on tables that signed-out visitors never need.
  • For which keys may live in frontend code at all, read API keys in AI-built apps.

Frequently asked questions

Do I need to hide or rotate my anon key?

No. Supabase describes the publishable key as safe to expose in web pages and apps. Anyone can copy it from your site. Protect your data with RLS and grants instead of hiding the key.

What is the difference between the anon key and the publishable key?

They play the same role. The legacy anon key is a long-lived JWT that starts with eyJ; the newer publishable key starts with sb_publishable_. Both act as the anon role until a user signs in.

Someone reported my anon key as a leaked secret. Is that a vulnerability?

The key on its own is not. The real question is what it can reach. Run the check on this page: if a visitor can read rows they should not, fix the table’s RLS, not the key.

Sources

  1. 1.Understanding API keys — Supabase Docs
  2. 2.Securing your API — Supabase Docs
  3. 3.Row Level Security — Supabase Docs

Find this in your own app

ShipRely reads your repository (read-only), proves each finding with file and line, and gives you a fix prompt to paste into your AI builder.

Run a demo audit
  • Read-only access to your repository
  • Every finding with file and line
  • Fix prompts for Lovable, Cursor, Claude Code and Bolt