Supabase RLS explained: row-level security for Lovable and Bolt apps
If you built your app with Lovable or Bolt, there’s a good chance your data lives in Supabase. And if there’s one thing I’d want every founder on Supabase to understand, it’s row-level security. It’s the difference between “each user sees their own data” and “anyone can read everything.”
You don’t need to be technical to understand it. Here’s the plain-English version.
Why your database is exposed by design
Most apps keep the database behind a server. The browser talks to the server, and the server decides what each user is allowed to see.
Supabase works differently. To make building fast, your app’s code in the browser talks to the database directly, using a public key that anyone can find. That’s normal and safe, but only if the database itself enforces the rules. Row-level security is how it does that.
So with Supabase, your security doesn’t live in your app’s screens. It lives in the database. If the rules aren’t there, hiding a button in the app doesn’t protect anything.
What row-level security is
Row-level security (RLS) is a set of rules on each table that answer one question: for this signed-in user, which rows can they read, add, change or delete?
A typical rule says something like “a user can see a project only if they own it” or “a user can see an invoice only if they belong to the company it was issued to.” Supabase checks these rules on every request, whoever sends it.
How it goes wrong in AI-built apps
- RLS is switched off. Depending on how a table was created, row-level security may not be on. With it off, anyone with your public key can read the whole table.
- RLS is on, but the rule allows everything. A policy that simply says
truepasses every request. AI builders sometimes write these to make an error go away. - Reading is protected, writing isn’t. A user can’t see other people’s records but can still change or delete them. Rules for reading and writing are separate, and both need checking.
- The admin key is in the browser. Supabase’s
service_rolekey skips every rule. It belongs on a server only. If it’s anywhere in your frontend code, every rule you’ve written is irrelevant. - Roles checked in the app, not the database. The app hides the admin page from normal users, but the database will still happily return admin data to anyone who asks for it directly.
- Files left public. Uploaded files have their own rules in Supabase Storage. Public buckets are fine for logos, not for contracts or private photos.
How to check your own app
You can do a first pass yourself in about fifteen minutes:
- Open your Supabase project and run the Security Advisor. It flags tables without row-level security and other common problems.
- Go through your tables one by one. Each one that holds user data should have RLS enabled.
- Read the policies. Anything that says
true, or that doesn’t mention the signed-in user (usuallyauth.uid()), deserves a closer look. - Search your frontend code for
service_role. It should never appear there. - Check Storage. Any bucket holding private files should not be public.
If that turns up problems, fix them before adding any new features. If it doesn’t, that’s a good sign, but not a clean bill of health. Getting the rules right for your business, like teams, invitations, admins and shared records, is where most of the real work is.
Writing the right rules
Good row-level security starts with a plain-English list: who your users are, what they own, and what they share. Only then does it become SQL. That’s also why a scanner can tell you a rule is missing but not what your rules should be.
This is one of the first things we check in every Lovable and Bolt project, and it’s where our Lovable rescue and Bolt rescue both start.
