Library / Users & access / Row-level security
No. 133·noun·also called RLS, row level security, RLS policy

Row-level security

Rules inside the database that decide which rows each signed-in user can read or change.

SPECIMEN · DIAGRAM · FLOW
PersonSigned-in user
AppYour app
ServiceRow policyIs this row yours?
DataInvoice rowsOnly yours come back
asks for invoicesquerieskeeps matches
Definition

What it is

Row-level security (RLS) is a set of rules stored inside your database that decide which rows each person can see or change. A row is one record, like one invoice. A rule might say: you can read an invoice only if it belongs to you.

The database enforces these rules itself, not your app's screens. That matters because hiding a button in the interface doesn't stop someone from asking the database directly. Without RLS, any signed-in visitor, and sometimes any visitor at all, may be able to read a whole table.

Use it on every table that holds user data, and check it before you launch. If you hit an error like "new row violates row-level security policy", the rules are working but are missing a case, often a rule for adding rows.

RLS is not login. Authentication says who you are; RLS uses that answer to decide what you can touch.

Say it like a builder

How to ask for it

Vague

“Make sure people can only see their own stuff.”

Precise

“Turn on row-level security for the invoices table. Add policies so a signed-in user can read, edit, and delete only the rows that belong to them, admins can read all rows, and anonymous visitors get no access.”

Why it works

"Only see their own stuff" could be done by hiding things in the screen, while "row-level security" puts the rule in the database and the prompt says who gets which access.

In the wild

You've seen this in

  • YYour Amazon order history showing only your orders, never someone else's
  • GGoogle Drive listing only the files you own or that were shared with you
  • TThe "new row violates row-level security policy" error that Supabase-backed apps built with Lovable show when a rule is missing
Usage note

Often confused with