Is the Supabase anon key safe to expose?
Yes, if Row Level Security (RLS) is on for every table it can reach. The anon key, and the newer publishable key that replaces it, are designed to ship inside your web or mobile app. They identify your project; they don’t protect your data. RLS does. Without it, anyone who copies the key from your page can read the table. The secret and service_role keys are different: they bypass RLS and must never leave your server.
The four Supabase keys, and which can be public
| Key | Looks like | In your frontend? | RLS |
|---|---|---|---|
| Publishable (new) | sb_publishable_… | Yes, safe | Enforced |
| Anon (legacy) | eyJ… (a JWT) | Yes, safe | Enforced |
| Secret (new) | sb_secret_… | Never | Bypassed |
| service_role (legacy) | eyJ… (a JWT) | Never | Bypassed |
Supabase is deprecating the legacy anon and service_role keys by the end of 2026. If your project still uses them, plan the switch to publishable and secret keys.
Telling the two legacy JWTs apart by eye is hard: both start with eyJ. Decode the middle part (for example with atob in your browser console): the anon key says "role":"anon", the service_role key says "role":"service_role". If you find the second one in your frontend code, treat it as leaked.
Why the public key is fine (with RLS on)
Every request to your Supabase database runs as a Postgres role. With the anon or publishable key, that role is anon for signed-out visitors and authenticated once someone logs in. Row Level Security policies are rules on each table saying which rows those roles may read or change, for example “a user can read only their own profile”.
So the key isn’t the lock. It’s closer to your app’s street address: everyone can see it, and the policies decide who gets through each door. If a table has RLS turned off, there’s no door: the public key reads all of it.
How to check your own tables in 2 minutes
In the Supabase SQL editor, list every table in the public schema and whether RLS is on:
select tablename, rowsecurity
from pg_tables
where schemaname = 'public'
order by rowsecurity, tablename;
Any row with rowsecurity = false is readable by anyone holding your public key. Turn RLS on, then add a policy for what each role should be allowed to do. For a typical profiles table:
alter table public.profiles enable row level security;
create policy "Users read their own profile"
on public.profiles for select
to authenticated
using ((select auth.uid()) = id);
Two things catch people out:
- RLS on with no policy blocks everything, including your own app. Add the policies your features need before you deploy.
- A policy of
using (true)is the same as no protection for that operation. AI app builders sometimes generate these to “make the error go away”. Search your policies fortrue.
If a secret or service_role key leaked
Assume it’s been copied. Supabase blocks secret keys from browser requests, but that doesn’t stop anyone using a copied key from a script or server. Supabase’s order of operations:
- Create a new secret key.
- Replace the old key everywhere it’s used (servers, edge functions, CI).
- Confirm nothing still uses the old one.
- Delete the old key. This can’t be undone, which is why it comes last.
Then move whatever needed the secret key into a server-side function, such as a Supabase Edge Function, so it never ships to the browser again.
How AppKavo checks this for you
The free live URL scan finds your Supabase URL and public key (anon or publishable) in your app’s JavaScript, then makes one read-only request to each of five common table names: users, profiles, accounts, orders and messages. If one returns rows, RLS isn’t protecting it. It also flags a new-format Supabase secret key (sb_secret_) found in the bundle; a legacy service_role JWT looks like any other JWT, so use the decode check above for that one. It never writes data and never uses a secret key to read anything.
Five table names is a quick check, not a full audit: a clean result doesn’t prove your other tables are protected. The SQL above checks all of them.
Check your app now
Paste your app’s URL. Read-only, free, no signup.
Scan my app freeQuestions
Can someone delete my data with the anon key?
Only if a policy allows it. RLS policies are set per operation (select, insert, update, delete). With RLS on and no delete policy, the public key can’t delete anything.
Should I hide the anon key in an environment variable?
You can, for tidiness, but it still ends up in the JavaScript your visitors download. Environment variables prefixed VITE_ or NEXT_PUBLIC_ are public by design. Only secret keys need hiding, and they belong on a server.
Is this different for a mobile app?
No. A key inside an Android or iOS app can be extracted from the build just as easily. The same rule applies: public key plus RLS, secret keys only on a server. AppKavo’s APK audit runs the same Supabase check on mobile builds.
Sources
Key types, deprecation timeline, header and leak-handling guidance from Supabase’s API keys documentation, checked 9 October 2026. Row Level Security behaviour from Supabase’s RLS guide.
More guides: all guides · Lovable security check