Guide

How to turn on Supabase RLS without breaking your live app

Last checked 17 Nov 2026 · 7 min read · by Ship Weekend

Short answer: write the policies before you switch RLS on, then enable it one table at a time, in a transaction, starting with your least important table. Postgres ignores policies on a table until RLS is enabled, so you can prepare everything in advance.¹ The moment RLS is on with no policy, the table returns nothing to your app.² That empty-app moment is what scares people off the fix, and you can avoid it.

This guide is for an app that already has real users. If you are pre-launch with only test data, you can be less careful: turn RLS on everywhere and fix what breaks.

Why turning on RLS "breaks" apps

When you enable RLS on a table, Supabase applies deny by default: until you add a policy, no data is reachable through the API with the publishable (anon) key.² Your front end does not crash. It just gets empty lists, so dashboards look wiped and sign-up flows that write a profile row fail.

Three things are usually behind it:

  1. No policy yet for an operation the app performs. A select policy alone does not allow insert, update or delete. Each needs its own policy.²
  2. The wrong role. A policy written to authenticated does nothing for signed-out visitors, which is usually what you want, but it also breaks public pages (pricing, a public profile) that read that table while logged out.
  3. Missing grants. A missing grant raises 42501 permission denied before any policy runs.² Not every Supabase project grants anon and authenticated access to new tables automatically, so check both.² Our 42501 GRANT fix guide covers that error.

Code using a secret / service_role key bypasses RLS, so server-side jobs and Edge Functions that use it keep working.² Anything that runs with the publishable key, including the browser, is affected.

Before you start (10 minutes)

  1. List your tables and what the app does with each. For every table in public, write down who reads it (signed-out, any signed-in user, only the owner) and who writes it. This list is your policy plan.
  2. Find the tables with RLS off. In the SQL editor:
select tablename
from pg_tables
where schemaname = 'public' and not rowsecurity;
  1. Check which column links a row to a user. Usually user_id (or id on a profiles table) holding auth.uid(). If a private table has no such column, add one before you write policies, or the only possible policy is "everyone" or "no one".
  2. Take a backup or confirm your project's backups are on. You are changing access rules, not data, but it costs nothing to check.
  3. If you can, rehearse on a copy first. A Supabase branch or a local supabase start project with the same schema lets you break things where nobody notices.

The safe order, one table at a time

Start with a low-stakes table, then move to the important ones (profiles, orders, messages) once the pattern works.

Step 1: Write the policies while RLS is still off

Policies on a table with RLS disabled exist but are ignored.¹ So you can add them without changing anything for users. A typical "users own their rows" set looks like this:

create policy "Owners read their rows"
on public.notes for select
to authenticated
using ( (select auth.uid()) = user_id );

create policy "Owners add their rows"
on public.notes for insert
to authenticated
with check ( (select auth.uid()) = user_id );

create policy "Owners edit their rows"
on public.notes for update
to authenticated
using ( (select auth.uid()) = user_id )
with check ( (select auth.uid()) = user_id );

create policy "Owners delete their rows"
on public.notes for delete
to authenticated
using ( (select auth.uid()) = user_id );

Supabase recommends the (select auth.uid()) form and an index on the column the policy filters on, so the policy stays fast as the table grows:²

create index if not exists notes_user_id_idx on public.notes (user_id);

Avoid two shortcuts that pass a "has a policy" check but still leak: using (true) on private data lets anyone read every row, and auth.uid() is not null lets any signed-in user read everyone's rows.²

If a table really is public (published posts, a product list), give it a select policy to anon, authenticated using (true) and no write policies for clients.

Step 2: Enable RLS and grants together, in one transaction

Postgres runs DDL inside transactions, so the switch and the grants land at the same moment, or not at all:

begin;
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;
commit;

Supabase's own procedure is the same: enable RLS, revoke the client roles, grant back only what each role needs, and keep grants and RLS in the same migration.² If you use migrations, put this in one rather than clicking it in the dashboard, so staging and production match.

Step 3: Test it straight away, as three people

Test right after the commit, before you move to the next table.

  1. Signed out: open the live app in a private window, DevTools → Network, filter for supabase. Responses from this table should contain no private rows. Our 5-minute leak check walks through it.
  2. As user A: sign in with a test account, create a row, edit it, delete it. If any of those fail, the matching policy or grant is missing.
  3. As user B: sign in with a second test account and try to open user A's row directly (by its URL or id). You should get nothing.

You can also simulate users in the SQL editor, as Supabase's testing examples do, inside a transaction you roll back:²

begin;
set local role authenticated;
set local request.jwt.claim.sub = '<user-A-uuid>';
select count(*) from public.notes;  -- only user A's rows
rollback;

Also run a fresh sign-up end to end. A profiles table with RLS on and no insert policy is the classic way sign-up breaks quietly.

Step 4: Keep a rollback, and know what it costs

If something important breaks and you cannot fix the policy within minutes:

alter table public.notes disable row level security;

That restores the old behaviour instantly. It also re-opens the table to whatever the grants allow, so treat it as a short pause while you fix the policy, not as a resting state.

Step 5: Repeat, then check the edges

Move to the next table. When every table is done:

Using Lovable, Bolt or Cursor to do it

It is fine to ask your AI tool to write the policies, but give it the order. A prompt that works:

For each table in public, list who should read and write it. Write select, insert, update and delete policies using (select auth.uid()) = user_id where rows belong to a user. Do not enable RLS yet. Then give me, per table, a single transaction that enables RLS, revokes anon and authenticated, and grants back only what the app needs. Do not use using (true) on any table holding user data.

Then apply one table at a time and run Step 3 after each. Check what it produces: an agent tests as the logged-in developer, so it rarely notices what a signed-out stranger or a second user can see.

FAQ

Will enabling RLS delete any data? No. RLS controls which rows each request can see or change. Rows that disappear from your app are hidden by a missing policy, not deleted.

My app shows nothing after I turned RLS on. What happened? RLS is on and there is no select policy (or no grant) for the role your app uses. Add the policy, check the grants, and test again. As a short-term pause you can disable RLS on that table while you fix it.

Does turning on RLS break my Edge Functions or backend jobs? Not if they use a secret / service_role key, which bypasses RLS. If the request carries a signed-in user's token, it runs under that user's policies instead.²

Should I enable RLS on every table at once? On a live app, no. One table at a time, tested after each, is slower but you always know what broke.


Want a second pair of eyes? The $49 Launch Check tests, with your permission, whether signed-out visitors can read your tables (a row count only, we keep no rows), looks for exposed keys on your live site, and gives you a plain-English fix list with copy-paste prompts for Lovable, Bolt or Cursor. The free Quick Check covers leaked keys, exposed files and other basics in about 20 seconds; it does not test database access.

Sources

  1. PostgreSQL docs, ALTER TABLE (ENABLE/DISABLE ROW LEVEL SECURITY: policies can exist while RLS is disabled and are then ignored; with RLS on and no policies, default deny applies): https://www.postgresql.org/docs/current/sql-altertable.html
  2. Supabase docs, Row Level Security: https://supabase.com/docs/guides/database/postgres/row-level-security
  3. Supabase docs, Advisors: https://supabase.com/docs/guides/observability/advisors