Is the Supabase anon key safe to expose in my app?

What a stranger can do with your anon key

Your app's code is downloaded by every visitor, so the anon key and your project address are visible to anyone who looks. With those two values, a person can talk to your database without using your app at all: list tables your policies allow, read rows, insert rows, call database functions, and download files from public buckets.

That's by design. Supabase expects every table to be protected by Row Level Security, so the key only opens what your policies allow. The problem is tables where RLS is off or too open: for them, the public key is effectively a master key.

# What anyone can run with your public values (replace the placeholders):
curl 'https://YOUR-PROJECT.supabase.co/rest/v1/profiles?select=*' \
  -H 'apikey: YOUR_ANON_KEY'

# If this returns rows, a stranger can read that table without signing in.

The key that must never be public

The service_role key (secret key) skips Row Level Security entirely. If it appears in your front-end code, in a VITE_ or NEXT_PUBLIC_ variable, or in a file the browser downloads, anyone can read and change everything. Rotate it immediately in the Supabase dashboard and move whatever needs it to a server function.

How to check it yourself

  1. In the Supabase SQL editor, list your tables and whether RLS is on: select tablename, rowsecurity from pg_tables where schemaname = 'public';
  2. For each table, run the curl above with your anon key (signed out, no user token). Tables with private data should return an empty list or an error.
  3. Search your project for service_role, the secret key, and any variable starting with VITE_ or NEXT_PUBLIC_ that holds a key. None of them should be the service role key.
  4. In Storage, check which buckets are public. Only files meant for anyone (logos, public images) should be there.

Prompt to fix it

Fix prompt

Make the app safe with a public anon key. Enable Row Level Security on every table in the public schema. For tables that hold private data, allow no access to the anon role and only allow signed-in users to read and change their own rows (user_id = auth.uid()). Keep public read access only on tables that are really public, and say which ones. Make sure the service_role key is never used in front-end code or in variables exposed to the browser; move any code that needs it to a server function. Make private storage buckets non-public. List every change.

Want us to run this test for you?

The US$9 crash test without code signs in as two test users on your live app and checks this for you: data between users, private pages and the API behind them, free vs. paid plans, and what your public Supabase key opens. You get the evidence and a fix prompt for each issue.

Related guides

Updated 2026-11-24