For Lovable, Bolt, Cursor and v0 apps
Is it safe to expose your Supabase anon key?
Direct answer
Yes, the anon key (or the newer sb_publishable_ key) is meant to be public, and anyone who opens your app can read it from the JavaScript. It is only safe when Row Level Security is on for every table and your policies limit rows to the right user. With RLS off, that same public key can read the table. The service_role or sb_secret_ key bypasses RLS and must never ship to the browser.
LeakLatch is a free, read-only scan of a live URL you own. It reports leaked secret keys in your JS bundles, Supabase tables that answer with your public anon key, and missing security headers. You get a risk score, redacted findings, and a fix prompt for Lovable, Cursor, or Claude.
What to do
Five checks for your own project
Use these on a project you own. The commands only read your own files; nothing here changes your app. Sources for Supabase's guidance: Supabase Docs, API keys and Supabase Docs, Row Level Security.
Step 1
Confirm the key in your frontend is the low-privilege one
Supabase lists the publishable key (sb_publishable_) as safe to expose in a web page, mobile app or source code, and the legacy anon key as its older version. The secret key (sb_secret_) and the legacy service_role key bypass Row Level Security and must only live on a server or in an Edge Function. If either of those is in your bundle, rotate it first.
Step 2
Turn on Row Level Security for every table in exposed schemas
Supabase's API keys guide says that when you use a publishable key, Postgres guards your data through the anon and authenticated roles, and for full protection you should enable RLS on all tables. A table without RLS in the public schema can be read through the Data API by anyone holding the public key.
Step 3
Review the policies granted to anon and authenticated
RLS on with a policy like using (true) is still open to everyone. Supabase recommends regularly reviewing policies for permissions granted to the anon and authenticated roles. Each select, insert, update and delete policy should limit rows to the signed-in user, for example auth.uid() = user_id.
Step 4
Remember what the public key does not protect
Supabase says publishable keys are not meant to protect against code analysis, the browser's network inspector, cross-site scripting, phishing or man-in-the-middle attacks, because anyone can retrieve them. Treat the key as public and put your protection in RLS policies and server-side checks.
Step 5
Test the live site, not only your local copy
Your hosting dashboard can hold different env values than your local .env, and new tables are often created without RLS after launch. After each deploy, search the build output with the commands below and test a table route with only the public key to confirm it returns nothing it shouldn't.
# Run in your own project folder after a production build.
# Vite (Lovable, Bolt): output in dist/ Next.js (Cursor, v0): output in .next/static/
# 1. Which Supabase keys ship to the browser? Prints only the first characters.
grep -rEoh "sb_(publishable|secret)_[A-Za-z0-9_-]{4}" dist .next/static 2>/dev/null | sort -u
# 2. Legacy JWT keys (anon and service_role both start with eyJ). Decode the middle part
# of each one and check the "role" claim: it must say anon, never service_role.
grep -rEoh "eyJ[A-Za-z0-9_-]{10,}.[A-Za-z0-9_-]{10,}.[A-Za-z0-9_-]{10,}" dist .next/static 2>/dev/null | sort -u
# 3. In the Supabase SQL editor: tables in the public schema without RLS.
# select tablename from pg_tables where schemaname = 'public' and rowsecurity = false;Copy-paste fix
Lock down Supabase with one prompt
Paste this into Lovable, Cursor, or Claude and point it at your own project. Review each change before you apply it, and rotate any secret key that already shipped.
You are helping me secure the Supabase setup of my own app. Keep existing features working. 1. List every Supabase key used in the frontend (VITE_ and NEXT_PUBLIC_ variables, hard-coded strings, committed .env files). Only the anon or sb_publishable_ key may stay there. 2. If a service_role or sb_secret_ key is used in the frontend, move that code into a Supabase Edge Function or server route that reads the key from a server-only secret, and remind me to rotate the old key. 3. List every table in the public schema and any other exposed schema, and enable Row Level Security on each one that has it off. 4. For each table, write select, insert, update and delete policies that limit rows to the signed-in user (for example auth.uid() = user_id), and remove any policy that uses true for the anon role unless the data is meant to be public. 5. Show me the SQL before running it, then give me a query I can run with only the public key to confirm private tables return no rows.
FAQ
Straight answers about the Supabase anon key
Is the Supabase anon key a secret?
No. Supabase describes the anon key as the legacy version of the publishable key, which is safe to expose online. Anyone who opens your app can read it from the JavaScript. It is only safe because Row Level Security decides what that key can reach.
What is the difference between the anon key and the publishable key?
The anon key is a long-lived JWT that starts with eyJ. The publishable key is a short string that starts with sb_publishable_. Both have low privileges. Supabase says it is deprecating the anon and service_role keys by the end of 2026 in favour of publishable and secret keys.
Can someone read my database with just the anon key?
Only what your Row Level Security policies allow. If a table in an exposed schema has RLS off, or a policy that allows everything, the public key can read it through the Data API. With RLS on and policies scoped to the signed-in user, it returns only what that user may see.
Is the service_role key safe to expose?
No. Supabase says secret keys and the legacy service_role key provide full access to your project's data, bypassing Row Level Security. Never put one in a VITE_ or NEXT_PUBLIC_ variable. If one shipped, rotate it in the dashboard and move that code into an Edge Function or server route.
Should I hide the anon key in an environment variable?
Using VITE_SUPABASE_ANON_KEY or NEXT_PUBLIC_SUPABASE_ANON_KEY is fine for configuration, but it does not hide anything: those prefixes copy the value into the JavaScript every visitor downloads. That is expected for the public key and a leak for any secret key.
What does LeakLatch check here?
LeakLatch loads the live URL you give it and its JavaScript bundles, read-only. It looks for Supabase service_role and secret keys plus other known secret key patterns, and checks whether Supabase tables answer with your public anon key. Secret values are redacted in the report. You must confirm you own the site or have permission to scan it. It is not a substitute for a full security audit.
Want this check done for you, read-only?
Paste a URL you own. LeakLatch returns a score, redacted findings, and a fix prompt.
Scan my site free