guide · AI apps

Supabase RLS: lock your data before launch

Your AI-built app works. The question is who else can read its database. Row level security is the answer, and it takes an afternoon to get right.

By NLY Media · Updated November 2026 · 7 min readBy NLY Media

Short answer

Supabase RLS (row level security) is a set of rules inside your database that decides which rows each person can read or change, and Supabase says to turn it on for every table your app can reach. Without it, anyone holding your app's public key can read and edit that table. Turn it on, write a policy for each table, keep your secret key on the server, then test with two different user accounts.

In this guide
  1. Why it matters
  2. How it works
  3. Keys
  4. Turn it on
  5. Test it
  6. Turning it off
  7. Questions people ask

What is RLS in Supabase, and why does your app need it?

Say you used an AI builder to make a booking app for a small Toronto yoga studio. People sign up, pick a class and leave a phone number. It works. You show the owner, and she's thrilled.

Here's the part the builder may not have explained. Supabase's own production checklist says: "The Data API exposes your tables to anyone who has your publishable key, and that key ships in your app." Anyone who opens the app in a browser can find that key. So the only thing between a stranger and every client's phone number is the rule set inside the database.

That rule set is row level security. Supabase describes it as "granular authorization rules that run inside the database." In plain words: for every table, you write down who may see or change which rows, and the database enforces it on every request, no matter what the app's screens do.

The warning in Supabase's docs is direct: "A table in an exposed schema without RLS is readable and writable by any role with a grant on it." That's why this matters more for AI-built apps than most. The app can look finished while the database is wide open.

How Supabase row level security works

You don't need to be a database person to follow this. Three ideas cover most of it.

Policies act like a filter on every query

Supabase puts it simply: "Think of a policy as adding a WHERE clause to every query." A policy is attached to a table and runs every time that table is touched. If the policy says a person can only see their own bookings, that filter is added whether the request came from your app, a script or someone poking at your API.

Grants and policies are two separate checks

Postgres checks two things before anyone touches a table. Grants decide whether a role can run an action, like reading or inserting, at all. Policies decide which rows that action applies to. Supabase's advice is to set both for every table you expose.

Signed out and signed in are different roles

Supabase maps every request to a role. A visitor who isn't signed in is "anon". Someone who is signed in is "authenticated". Most Supabase RLS authenticated rules are written for that second role, for example: signed-in people may read rows where they are the owner. Rules for anon are usually much tighter, or missing on purpose.

One more thing worth knowing. Once RLS is on for a table and no policy exists, Postgres uses "a default-deny policy," so nobody can see or change any rows. If your app suddenly shows empty lists after you switch RLS on, that's usually why. It's a good sign. You now add the policies you need, one at a time.

The keys that bypass RLS in Supabase

Not every key plays by these rules. This is the part most worth getting right, because one misplaced key undoes all your policies.

PublishableSecret
Where it goesAnything you ship: browser, mobile app, CLI, scriptAnything you control: server, Edge Function, cron job
Who can see itAnyone. It's not a secretOnly you. It must never leave your control
Respects RLS?Yes. It only reaches what your policies allowNo. It bypasses RLS completely
Older nameanon keyservice_role key
New formatsb_publishable_...sb_secret_...

When people search for Supabase bypass RLS, this is the answer: the secret key and the older service_role key skip your policies. Supabase is clear that they "are never safe to expose because they bypass RLS. Only use your secret and service role keys on the backend." In Postgres more broadly, superusers, roles with the BYPASSRLS attribute and usually the table's owner also skip row security.

A timing note: Supabase says it is "deprecating the anon and service_role keys by the end of 2026" in favor of the publishable and secret keys. If your app still uses the old ones, that change is weeks away, so plan the swap now.

AI app development by NLY Media

Want it done for you? See what we build and how we work.

See AI app development →

How to enable RLS in Supabase

Supabase's checklist points you to the dashboard: enable row level security "on every table in the Database > Tables section of the Supabase Dashboard." Here's the full order we'd follow.

  1. Open your project in the Supabase dashboard and go to Database, then Tables.
  2. For each table your app can reach, turn RLS on. Don't skip the small ones; a settings or logs table can leak just as much.
  3. Expect your app to show empty data for a moment. That's default-deny doing its job.
  4. Write one policy per action you need (read, insert, update, delete), giving the least access that still lets the app work.
  5. On older projects that still grant anon and authenticated by default, revoke those grants where they aren't needed. Supabase notes that adding policies doesn't remove them.
  6. Search your app's front-end code for the secret or service_role key. If it's there, move that work to a server or Edge Function and rotate the key.

Supabase RLS policy examples, in plain words

You'll write the exact policy in SQL or with your builder's help, but decide the rule in plain words first. These four cover most small apps:

  • Personal notes: a signed-in person can read and change only the rows they created.
  • Public price list: anyone can read it, signed in or not, and nobody can write to it from the app.
  • Team workspace: people see only rows that belong to their own company. This is the rule multi-customer apps live or die by.
  • Admin-only table: no policy for anon or authenticated at all, so only server code using the secret key can touch it.

How to test Supabase RLS, not just switch it on

Flipping the switch takes a minute. Knowing your rules actually hold is the harder job, and it's where builders tend to get stuck. Three things go wrong most often: a policy that lets in more people than you meant, a screen that hides other people's data while the table behind it stays open, and a secret key that ended up in the front-end code.

A simple way to test Supabase RLS without special tools:

  • Make two test accounts, A and B. Sign in as A, create some data, then sign in as B and try to load A's rows. You should get nothing.
  • Sign out completely and try the same requests. Signed-out visitors should see only what you meant to be public.
  • Try writes too, not just reads. A rule that blocks reading but allows updates is still a leak.
  • Run Supabase's Security Advisor, which flags database security issues, and fix what it finds.
  • Remember RLS controls rows, not columns. If some columns in a readable table are private, Supabase has separate column-level security docs for that.

How to disable RLS in Supabase, and Supabase security overall

RLS is a per-table setting in Postgres, so it can be switched off the same way it was switched on. The real question is whether you should. For any table your app can reach with the publishable key, the answer is almost always no. Supabase's checklist says a table without RLS and reasonable policies "lets any client read and change its data."

If RLS is blocking you while you build, the fix is a correct policy, not turning it off. Builders often switch it off "just for now", ship, and forget.

Is Supabase itself secure?

Supabase security comes in two layers. Supabase runs the platform and publishes a security page and trust center. Your app's data rules are yours to set. Its checklist exists to "secure your project before real users depend on it" and covers "the settings that, when missed, leave data exposed or accounts open to takeover."

Most ai app security articles talk about prompt injection and model risks. For a typical AI-built app holding customer details, the first check is far plainer: are the database rules on and correct? Once they are, work through our vibe coding security guide for the rest of your pre-launch check. If you'd rather have someone review it, NLY Media, a web design and development studio in Toronto, offers AI app development as one of its seven services.

Supabase RLS: questions people ask

What does RLS do in Supabase?

It decides, row by row, what each person can read, add, change or delete in a table. The rules run inside the database, so they apply to every request that uses your publishable key, whatever your app's screens do.

What does RLS do in a database?

In Postgres, row security policies restrict, per user, which rows normal queries can return or change. By default a table has no policies. Once RLS is turned on and no policy exists, nobody can see or change any rows until you add one.

How do I disable RLS in Supabase?

RLS is a per-table setting, so it can be turned off. But on any table your app reaches with the publishable key, turning it off lets anyone read and change that data. If RLS is getting in your way, write the policy your app needs instead.

How secure is the Supabase database?

Supabase runs the platform and publishes its security and compliance material. How safe your data is depends on your settings: RLS on every exposed table, sensible policies, and the secret key kept on the server. Supabase's production checklist covers these.

Should I enable automatic RLS on Supabase?

Supabase's docs say every table in an exposed schema should have RLS, so a setting that turns it on for you points the right way. Check how the option works in your dashboard today, and still write and test policies for each table.

More guides

All guides →

let’s talk

How do you
want to start?