Ship-Ready / Guides

My Supabase anon key is in the browser. Is that a problem?

Short answer: the anon key being visible is normal. Two other things decide whether you have a problem, and you can check both in about 5 minutes.

The anon key is public on purpose

Supabase's client libraries need the anon (or "publishable") key in the frontend to talk to your database. Every visitor downloads it with your JavaScript. Hiding it, obfuscating it or moving it to an env var with a VITE_ or NEXT_PUBLIC_ prefix changes nothing: it still ships to the browser. A security scanner flagging "Supabase key found in bundle" is telling you something you can't and don't need to change.

What the anon key can do is decided entirely by your database: Row Level Security (RLS) policies and table grants. That's the real lock.

Problem 1: the key that must never be there

Supabase gives you a second key, service_role (or a "secret" key). It bypasses RLS completely. If it's in your frontend, anyone can read and change everything. Check:

grep -rnE "service_role|SUPABASE_SERVICE|sb_secret_" src/ app/ components/ public/ 2>/dev/null
grep -rnE "(NEXT_PUBLIC|VITE|EXPO_PUBLIC)_[A-Z_]*(SERVICE|SECRET)" . --include=*.env* 2>/dev/null

You can also decode a key: a JWT-style key has "role":"anon" or "role":"service_role" in its middle part (paste it into any JWT decoder you trust, or echo <middle part> | base64 -d). If a service_role key was ever shipped or committed, rotate it in the Supabase dashboard; deleting the line isn't enough because it's still in your git history and in deployed bundles.

Problem 2: the lock that isn't locked

If RLS is off on a table, or a policy says using (true), the public anon key can read those rows. Run this in the SQL editor of your own project:

select tablename from pg_tables
where schemaname = 'public' and not rowsecurity;

select tablename, policyname, cmd, qual
from pg_policies
where schemaname = 'public' and (qual = 'true' or with_check = 'true');

Empty results on both is a good start. Then try what a stranger sees, against your own project only:

curl "https://<project-ref>.supabase.co/rest/v1/<private_table>?select=*&limit=1" \
  -H "apikey: <your anon key>"

[] is what you want for private data. If rows come back, add a policy such as using (auth.uid() = user_id).

What this looks like at scale

In November 2026 a Hamburg security firm checked 34,545 Lovable apps on Supabase. On 7,403 of them it could read tables holding email addresses with nothing but the public key every visitor gets (Crissy Field). The key wasn't the bug; the rules were. The firm notes this is not a confirmed leak rate and its sample isn't representative of all Lovable apps.

Quick decision table

Anon key visible in browser ............ normal, no action
service_role / secret key in frontend .. rotate now, move to server only
RLS off on a table with user data ...... enable RLS + add policies
using (true) on private data ........... scope to auth.uid()
curl with anon key returns private rows  fix policies before launch

More checks (views that skip RLS, SECURITY DEFINER functions, second-user test): the 10-minute self-check.

Rather not do it by hand?

Run the free quick scan

Ship-Ready Lite's quick scan checks your code for leaked service keys, secrets in public env vars, RLS turned off and using (true) policies, offline and read-only. The Crew ($39) runs the full 59-check scan.