Supabase Row Level Security Explained: A Guide For Lovable And Bolt Builders
Supabase row level security (RLS) in plain English: what it does, how to check your Lovable or Bolt app in 10 minutes, and the policies to copy.

IN THIS POST
Row Level Security is the one setting standing between a stranger and your users' data. Here is what it does, how to check yours and the policies to copy.
If you built your app with Lovable or Bolt and it saves data, there is a good chance it runs on Supabase. That is a solid choice. It also means your app's front end talks straight to your database from the visitor's browser, and the only thing standing between a stranger and your users' data is a setting called Row Level Security.
Supabase row level security, usually shortened to Supabase RLS, is the setting AI-built apps most often get wrong, and one of the easiest to fix once you know what you are looking at. Let's walk through it without the jargon, check your own project in about ten minutes and leave you with policies you can copy.
What Row Level Security Actually Does
Row Level Security is a feature of Postgres, the database underneath Supabase. You switch it on for a table, then write rules called policies that decide which rows each person can read, add, change or delete.
The easiest way to picture it: a policy adds an invisible filter to every query. If your rule says "users can only see their own notes", a request for all notes quietly becomes "all notes where the owner is this signed-in user". The browser never receives the other rows, even if someone tampers with the request.
Supabase sorts every request into one of two roles:
- anon: someone who is not signed in. Your app's public key identifies them.
- authenticated: someone who is signed in.
That public key sits in your front-end code by design, and it is not a secret. What protects your data is not hiding the key but the rules attached to each table. Our glossary has a short explainer on row level security if you want the one-paragraph version.
One detail catches people out. Switching RLS on without writing any policy locks the table completely, so your app suddenly shows empty lists. Many builders respond by turning RLS off again. Please do not. Empty results mean the lock is working, and you now need to add the rules that let the right people in.
Is Lovable Secure? Where Supabase RLS Goes Wrong
People often ask whether Lovable is secure, and the honest answer is that the platform is rarely the weak point. Lovable security issues almost always come from how the generated app is configured. The tool writes working code fast, and "working" does not mean "locked down". The same applies to Bolt and other builders.
These are the patterns we see most often:
- RLS never switched on. The table works perfectly in the preview, so nobody notices. Anyone who copies the public key from your site can read, edit or delete every row.
- A policy that says "true". The AI hit an empty-list error and added a rule allowing everyone to read everything. It fixes the error and removes the protection.
- Rules that check the wrong thing. A policy checks that someone is signed in, not that the row belongs to them. Any user can then read any other user's data.
- Views that skip the rules. A view built over a protected table can hand out every row, because views ignore RLS by default unless you set them up correctly.
- The service role key in the front end. This key ignores RLS entirely. If it appears in browser code, every rule you wrote is bypassed. Keep the service role key on the server only.
Check Your Supabase RLS In 10 Minutes
You do not need to read SQL fluently to run these checks. Work through them in order.
- Run an outside-in scan. A quick check reads your live site the way a stranger would and flags tables that answer to anyone. The guide to running your first scan shows how, with no sign-up.
- Open the Supabase dashboard. Go to Table Editor and look at each table. Supabase labels tables that have RLS switched off.
- List the policies on each table. A table with RLS on and zero policies is locked. A table with a policy that reads using (true) is open to whoever the policy names.
- Test as a signed-out visitor. Open your app in a private window without logging in and see what loads. Anything private that appears is a leak.
- Test as a second user. Create two accounts. Add data on account A, then log in as account B and try to find it. If you can, your policies check sign-in but not ownership.
- Fix, then test again. Never assume the fix worked. Repeat steps 4 and 5.
Copy These Four Supabase RLS Policies
This table maps common situations to the policy shape you need. Swap the table and column names for your own.
First, turn RLS on and remove access you do not need. Supabase's own documentation recommends this for every table in an exposed schema, and notes that adding policies does not remove existing grants, so revoke first and grant back only what each role needs:
alter table public.notes enable row level security; revoke all on table public.notes from anon, authenticated; grant select, insert, update, delete on table public.notes to authenticated;Then write one policy per operation. This is the owner-only pattern, where each person sees and edits only their own rows:
create policy "Users can view their own notes" on public.notes for select to authenticated using ( (select auth.uid()) = user_id ); create policy "Users can add their own notes" on public.notes for insert to authenticated with check ( (select auth.uid()) = user_id ); create policy "Users can edit their own notes" on public.notes for update to authenticated using ( (select auth.uid()) = user_id ) with check ( (select auth.uid()) = user_id ); create policy "Users can delete their own notes" on public.notes for delete to authenticated using ( (select auth.uid()) = user_id );Two things are worth understanding here. using decides which existing rows a person can touch. with check decides what a new or changed row may look like, which stops someone saving a row that belongs to another user. Naming the role with to authenticated means the rule never runs for signed-out visitors. Supabase also recommends wrapping auth.uid() in select for speed, and adding an index on the user_id column as the table grows.
If writing these by hand feels daunting, paste the fix prompt from your scan report into Lovable or Bolt, and read the guide to reading a scan report first so you know what it is changing. Then always run the two-account test, because AI tools can write a policy that looks right and still checks the wrong column.
Avoid These Mistakes After Switching RLS On
Even builders who switch RLS on can end up exposed. Check for these:
- Using user_metadata for permissions. Signed-in users can edit this field themselves, so a policy that trusts it can be talked into granting admin rights. Keep authorization data in app_metadata, which users cannot change.
- Public views over private tables. On Postgres 15 and above, create views with security_invoker = true so they respect the table's rules.
- Policies that read each other. Two tables whose policies depend on one another can trigger an "infinite recursion" error. A small helper function marked security definer breaks the loop, but pin its search_path and keep it out of exposed schemas.
- Public storage buckets. RLS covers database rows. Uploaded files have their own rules, so check any storage bucket separately.
- Skipping the test. A policy you have not tried to break is a guess. Test as a signed-out visitor and as a different signed-in user every time you change one.
Supabase RLS looks technical, but the idea is simple: every table decides for itself who gets in. Ten minutes of checking now is far cheaper than finding out from a user later.
References
Does your app have any of these problems?
Paste your website for a free quick check. About a minute, and nothing on your site is changed.


