Is the Supabase anon key safe to put in your frontend? Yes, and you have no real choice about it: a browser app cannot talk to Supabase without it. But the yes comes with a condition that does all the work. The key is safe if, and only if, every table, view, function and storage bucket it can reach is protected by grants and Row Level Security policies that say what you mean. If one of them is not, the key is a read (or write) key to that data, and it is sitting in every visitor's browser.

So the useful question is not "can I expose the Supabase anon key?" It is "what does my anon key open?" That takes about ten minutes to answer, and the queries are below.

What the anon and publishable keys can and cannot do

Supabase's API keys guide puts it neatly: the publishable key is taped to the front door and only opens the lobby. The key does not identify a person. It identifies your app, and it maps to a Postgres role:

Key you send User signed in? Postgres role that runs the query
Publishable (sb_publishable_...) or legacy anon JWT No anon
Publishable or legacy anon Yes (their session token rides along) authenticated
Secret (sb_secret_...) or legacy service_role JWT Not applicable service_role, which has BYPASSRLS

What the anon key can do is anything the anon role is allowed to do, through every door Supabase opens: the REST Data API, the RPC endpoint for functions, Storage, Realtime and the Auth endpoints (including sign-up, if you allow it). It does this without your frontend in the way. Anyone can copy the key from DevTools and call https://<ref>.supabase.co/rest/v1/<table> with curl.

What it cannot do is bypass RLS, read a table the anon role has no grant on, or act as a specific user without that user's session token. Postgres checks the grant first, then the policies. No grant means a permission error; RLS on with no matching policy means an empty result.

That last point matters for the "can I expose it" question. Hiding the key buys you nothing. Supabase lists what publishable keys are not meant to protect against, and reverse engineering and the browser's Network tab are both on it. Assume the key is public, because it is.

Legacy anon key and publishable key behave the same

If your project predates Supabase's new key format, your frontend probably ships a long string starting eyJ. That is the legacy anon key, a JWT with "role": "anon" inside it. Newer projects ship a short sb_publishable_... string instead. For safety purposes they are the same thing: both resolve to the anon role, and both are only as safe as your policies.

So a tutorial or AI assistant that has you paste an eyJ... key into the frontend is out of date, not dangerous. (Supabase is deprecating the legacy keys by the end of 2026, so move to the publishable key when you next touch the config.) The full key table, including how to tell the two legacy JWTs apart by decoding them, is in our outside-in Supabase security scan. If the JWT you decode says service_role, stop reading this and go to what to do when a service role key is exposed.

Decision flow for whether a Supabase publishable or anon key is safe: for each table, view, function and bucket the key can reach, check RLS and the policy, security_invoker on views, security definer and EXECUTE on functions, and public status on buckets. Only if every object passes is the key safe The key is safe only when every object passes its check. One open table is enough to make the answer no.

The three ways an exposed anon key goes wrong

Nearly every "my Supabase data was public" story is one of these. None of them is about the key.

1. RLS is switched off on a table

A table in the public schema with RLS disabled, plus the default grants, is readable and often writable by anyone holding the anon key. The dashboard's Table Editor turns RLS on for new tables by default. Tables created by a migration, by raw SQL in the editor, or by an AI tool writing SQL for you, get exactly what the SQL says. If nobody wrote alter table ... enable row level security, it is off.

The Security Advisor flags this as 0013_rls_disabled_in_public. It is the one finding that should stop a launch outright.

2. RLS is on, but the policy says USING (true)

This is the more common failure in generated code, because it looks fixed. RLS is enabled, the advisor's headline lint goes quiet, and the policy reads:

create policy "Enable read access for all users"
on public.notes for select
using (true);

using (true) means every row passes. Without a to clause the policy applies to every role, anon included. Narrowing it to to authenticated helps less than it looks if sign-up is open, because anyone can become authenticated with one request. We recorded exactly this happening, with the requests and responses, in the USING (true) demonstration: RLS on, Security Advisor quiet, and user A reading user B's note.

A policy that protects per-user data compares a column to the caller, for example using ((select auth.uid()) = owner_id).

3. Security definer views and functions

Both of these run with the rights of whoever created them, which on Supabase is usually postgres, a role that bypasses RLS.

Views. Postgres creates views with owner's rights by default, so a view over a perfectly protected table can hand every row to the anon role. Supabase's RLS guide is blunt about it: views bypass RLS by default. On Postgres 15 and later, create views with (security_invoker = true) so they obey the caller's policies (the option is documented under CREATE VIEW). The advisor lint is 0010_security_definer_view.

Functions. A function declared security definer in an exposed schema is callable over /rest/v1/rpc/<name> and runs as its owner. And unless you have changed the defaults, Supabase's Securing your API page notes that new functions are executable by every role. So a helper called get_invoice(invoice_id uuid) that selects by ID and checks nothing else is an open door. Keep security definer functions in a schema that is not exposed (Supabase suggests private), set search_path = '', and revoke execute from public and anon. The lint is 0028_anon_security_definer_function_executable.

Storage deserves a footnote here. A bucket marked Public serves any file to anyone who has its URL, whatever your policies on storage.objects say; policies still govern uploads, deletes and listing (bucket fundamentals). Fine for logos. Not fine for invoices.

A 10-minute check of what your anon key can reach

This is one query rather than a full audit. Run it in the SQL editor of a project you own; it only reads catalogue tables. It lists every object in public (plus storage buckets) that the anon role can reach through one of the three failure modes above.

-- What can the anon role reach, and why might it be open?
select 'table' as kind, c.relname::text as name, 'RLS off' as problem
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind in ('r', 'p')
  and not c.relrowsecurity
  and has_table_privilege('anon', c.oid, 'select, insert, update, delete')
union all
select 'table', tablename::text, 'policy passes every row: ' || policyname
from pg_policies
where schemaname = 'public' and (qual = 'true' or with_check = 'true')
union all
select 'view', c.relname::text, 'runs with its owner''s rights'
from pg_class c join pg_namespace n on n.oid = c.relnamespace
where n.nspname = 'public' and c.relkind in ('v', 'm')
  and has_table_privilege('anon', c.oid, 'select')
  and (c.relkind = 'm'
       or coalesce(array_to_string(c.reloptions, ','), '') !~* 'security_invoker=(true|on|1|yes)')
union all
select 'function', p.proname::text, 'security definer, anon can execute'
from pg_proc p join pg_namespace n on n.oid = p.pronamespace
where n.nspname = 'public' and p.prosecdef
  and has_function_privilege('anon', p.oid, 'execute')
union all
select 'bucket', id, 'public, any file readable by URL'
from storage.buckets where public
order by 1, 2;

An empty result is what you want. Each row is either a deliberate public object (a product catalogue, a logo bucket) or a leak, so decide which, out loud. Materialised views appear whenever anon can select from them, because they cannot use security_invoker and ignore RLS altogether; revoke the grant. The policy rows include policies for every role, so a to authenticated using (true) shows up too, which is right if anyone can sign up.

What the query cannot judge is whether a policy that does compare columns compares the right ones. Reading every policy as a sentence, and the storage policies, is step two of the Supabase RLS audit.

Then prove one table from outside, with only the key your site ships. A table you expect to be private should come back as [] or a permission error, never rows:

curl -s "https://$REF.supabase.co/rest/v1/notes?select=*&limit=3" \
  -H "apikey: $SUPABASE_PUBLISHABLE_KEY"

An empty array can also just mean an empty table, so test against a table you know has data. And this only tests the anon role. The failures that hurt most are between two signed-in users, which needs two accounts and one request each; the five checks for whether other users can see your data cover that in about half an hour.

When to worry, and when not to

Not worth worrying about:

Worth worrying about, roughly in order:

So, is the Supabase anon key safe?

The Supabase anon key in your frontend is not a secret and was never meant to be. Treating it as one (obfuscating it, proxying every request to hide it) adds work and protects nothing. The protection lives in Postgres: grants, RLS, the rights views and functions run with, and whether buckets are public. If those are right, the key is harmless. If one of them is wrong, rotating the key will not help either, because the new one opens the same doors.

What the ten-minute check will not tell you is whether your policies match your business rules. auth.uid() = user_id passes every query above and is still wrong if users are meant to share records inside a team, or if the real boundary is an org_id the policy never checks. That needs two accounts and someone who knows what each user is supposed to see. It is what the 5-Day Two-Account Check does on your live app, if you would rather not be the one trying.