Guide
Is your Supabase anon (publishable) key safe to expose? What it can and can't do
Short answer: yes. The anon key, and its newer replacement the sb_publishable_... key, is designed to sit in your web page, mobile app and even your public source code.¹ But "safe to expose" has a condition: it is only safe if Row Level Security (RLS) and grants decide what it can reach. The key opens the front door. Your policies are the locks inside. And one thing it must never be used for is proving who is calling, for example in an Edge Function.
If you've found your key in DevTools and panicked, you probably haven't found a problem. If you've found a key starting sb_secret_, or a JWT whose role is service_role, you have, and the service_role key guide is the one to read.
What the key identifies: your app, not your user
Supabase's docs draw the line clearly. An API key tells your project what is calling: a web page, a mobile app, a server. Supabase Auth tells it who is calling, when someone is signed in.¹
The key maps to a Postgres role, and that role is what your policies match on:¹
| Request | Postgres role |
|---|---|
| Publishable key, nobody signed in | anon |
| Publishable key, user signed in | authenticated |
| Secret key | service_role (bypasses RLS) |
So anyone who copies your key can send requests to your API as anon. They can do exactly what your grants and policies allow anon to do, and nothing more. They can also try signing up. If your app lets anyone create an account, they can become authenticated too.
What the key does not protect against
Supabase is explicit that a publishable key doesn't defend against code analysis, the browser's Network tab, or phishing, because anyone can retrieve it.² That means these are all normal and aren't leaks:
- The key appears in your bundled JavaScript.
- It appears in the Network tab of every request.
- It's committed to a public GitHub repo.
Hiding it behind a proxy doesn't add much, because the browser still needs it. Spend the effort on what it can reach.
Step 1: Check what anon can read (5 minutes)
Do this on your own project.
In the browser (safest). Open your live site in a private window, signed out. Open DevTools, Network, reload, and filter for supabase. For each call to /rest/v1/..., open the response and ask whether you'd be happy for a stranger to see it. Public product lists are fine. Emails, orders and messages aren't. Our 5-minute check walks through it in more detail.
From a terminal (read-only). Replace the project URL, key and table name, and send a plain GET:
curl -s "https://YOUR-PROJECT.supabase.co/rest/v1/your_table?select=*&limit=1" \
-H "apikey: YOUR_PUBLISHABLE_KEY"
Reading the response:
- Rows come back and the table holds private data: that's a leak. Turn on RLS and fix the policy.
[]can mean RLS is working, or the table is empty. Test with a table you know has rows.- A
42501permission error means the role has no grant on the table, which is a different failure from an empty result.³ See Supabase 42501 and the GRANT fix.
Use the table routes for testing. The Data API's root path, GET /rest/v1/, accepts only secret keys, so a publishable key gets a 401 there even though it works fine.¹ Don't test writes against live data.
Step 2: Remember authenticated isn't "private"
The most common mistake after "RLS is off" is a policy written to authenticated using (true), or using (auth.uid() is not null). Those look safe because they say "logged in". But if anyone can sign up, any stranger becomes a logged-in user in a minute and reads every row. A private table needs a policy that ties each row to its owner, like (select auth.uid()) = user_id.³ The change-the-ID test shows how to check with two accounts.
Step 3: Treat Edge Functions as your own responsibility
This is where "it has the anon key" gets mistaken for "it's authenticated".
When someone calls an Edge Function, Supabase's verify_jwt platform check is on by default.⁴ But the docs state that for the new publishable and secret keys, passing that check doesn't authenticate the caller, and that Edge Functions need to authorize API keys in code.¹ In plain terms: a caller holding only your public key has proven they have your app's public key, which is something anyone can copy. They haven't proven they're a user.
What to do:
- For functions that act on a signed-in user's behalf, require a user JWT. Supabase's
@supabase/serverwithSupabase({ auth: 'user' })does that and gives you a client scoped to the caller's RLS policies.⁴ - Be careful with the admin client. Supabase warns that a handler that queries a shared table through
ctx.supabaseAdminwithout filtering by the caller's ID returns every user's rows, because it bypasses RLS.⁴ Use the user-scoped client by default. - Use
verify_jwt = falseandauth: 'none'only for functions that authenticate callers some other way, such as Stripe webhooks, where you check the provider's signature yourself.⁴ Our Stripe webhooks with Supabase guide shows the setup. - Don't turn off
verify_jwtjust to clear a 401 in development. That removes the platform's check and leaves your code as the only guard.⁴ - Functions that call a paid API or send email also need a rate limit. Supabase's own limits only cover Auth endpoints. See Supabase auth rate limits before launch.
A short checklist
- Only
sb_publishable_oranonkeys appear in your front end. Nosb_secret_, noservice_roleJWT. Still onanon? Supabase is deprecating it in early 2027, so move to the publishable key. - RLS is on for every table in an exposed schema, and each private table has a per-owner policy.
- Grants match what each role should do (see the GRANT fix).
- Every Edge Function that touches user data checks a user JWT, or a signature, in code.
- You've tested signed out, then as a second user.
The RLS launch checklist takes you through the database side, and the free Quick Check is a quick outside-in look for the opposite problem, a secret key that ended up in your JavaScript. It's a GET-only scan of what your page loads. It doesn't log in, and it doesn't test RLS or your functions.
FAQ
Is it safe to put my Supabase anon key in a public GitHub repo?
Supabase lists source code among the places a publishable key can be exposed.¹ What matters is that RLS is correctly set up. A service_role or secret key in a repo is a different matter and needs rotating.
Should I rotate my anon key?
Not because it's visible. You'd only rotate it if you rotate the legacy JWT secret, for example after a service_role leak, in which case the anon key changes too and you must ship the new one.⁵
Can someone delete my data with the anon key?
Only if your grants and policies let anon (or any account they could create) do it. Table protection is about grants and RLS, so check both for insert, update and delete as well as select.
Want a second pair of eyes? The $49 Launch Check looks for exposed keys on your live URL and, with your permission, checks whether anonymous visitors can read your tables. We never need your passwords or keys.
Sources
- Supabase docs, API keys (publishable vs secret keys; keys identify the app, not the user; role mapping;
GET /rest/v1/accepts only secret keys;verify_jwtpassing doesn't authenticate a caller; Edge Functions authorize keys in code): https://supabase.com/docs/guides/api/api-keys - Supabase docs, API keys: Security reference (what publishable keys don't protect against): https://supabase.com/docs/guides/api/api-keys
- Supabase docs, Row Level Security and Securing your API (grants first, then policies;
42501vs empty result; per-user policies): https://supabase.com/docs/guides/database/postgres/row-level-security · https://supabase.com/docs/guides/api/securing-your-api - Supabase docs, Securing Edge Functions (
verify_jwtdefault,withSupabaseauth modes,supabaseAdminbypasses RLS,auth: 'none'for signed webhooks): https://supabase.com/docs/guides/functions/auth - Supabase docs, Rotate a leaked API key (legacy JWT secret): https://supabase.com/docs/guides/security/rotate-leaked-api-keys