How-to

Supabase Row-Level Security, explained

Published 21 October 2026 · 7 min read

If you built your app on Supabase, there is one setting that decides whether your users' data is private or quietly available to anyone: Row-Level Security (RLS). Get it right and the database enforces your rules for you. Skip it, and the key sitting in every visitor's browser can be used to read or change rows it should never touch.

This guide explains RLS in plain English, shows you how to turn it on, gives you copy-paste example policies, and walks through the three mistakes that trip up almost every no-code and AI-built app.

Why the key in the browser is not a secret

Supabase gives your app two main keys. The anon key (the "public" or "publishable" key) ships to the browser so your front end can talk to the database. The service-role key is an all-powerful admin key that is meant to live only on a server and bypasses every security rule.

Here is the part people miss: the anon key is public by design. Anyone can open your site, find it in the network requests, and start making their own database calls. It is not a password. The only thing standing between that key and your data is the set of rules you write. Those rules are Row-Level Security.

What Row-Level Security actually does

RLS lets the database check, row by row, whether the current request is allowed to see or change that specific row. Instead of trusting your app's code to filter data correctly, the rule lives in the database and applies to every query, no matter where it comes from.

A policy typically compares the logged-in user's ID to a column on the row. Supabase exposes the current user's ID through the function auth.uid(). So a rule like "you can only read rows where user_id equals your own ID" means that even if someone asks for every row in the table, the database hands back only theirs.

One critical detail: when RLS is turned on but no policy exists, the default is to deny everything. That is the safe default. The danger is the opposite case, where RLS is never turned on at all.

How to enable RLS on a table

In the Supabase dashboard, open Table Editor, select your table, and look for the RLS toggle, or go to Authentication → Policies. You can also do it in the SQL editor:

Do this for every table that holds user or business data, including join tables and anything you created quickly during a build.

Example owner-based policies

These assume a table with a user_id column that stores the owner's ID. They give each user access to only their own rows:

The using clause controls which existing rows a user can see or act on. The with check clause controls what new or updated rows are allowed, which stops someone from writing a row and stamping it with someone else's user_id. Write separate policies for select, insert, update, and delete so each action is deliberate.

The three mistakes that cause data leaks

A quick checklist

Check your app in 30 seconds

Run Faultline's free surface scan on any app in seconds. (Deep data-exposure scanning is live for Base44, with more platforms rolling out.)

Run a free scan

Faultline's free surface scan checks any website's TLS, security headers, and DNS/email hygiene, which is a solid first look at your exposure. It does not yet deep-scan Supabase data, so for RLS the best move is the manual checklist above: open each table, confirm RLS is on, and review every policy. Our deep data-exposure engine is live for Base44 today and rolling out to more platforms.

Related: Is Supabase secure? · Is Lovable secure?