Glossary / Row-level security

What is row-level security?

Row-level security (RLS) is a database feature that decides, row by row, which records each user is allowed to read or change, so a customer only ever sees their own orders even if the app asks for more.

Without it, the rule "users only see their own data" lives in the app's code. If one screen or API forgets to check, private data can leak.

With row-level security, the rule lives in the database itself. You write a policy such as "a row in orders is visible only when its customer_id matches the signed-in user", and the database applies it to every query.

Postgres supports row-level security, and some backend services rely on it heavily because their apps talk to the database straight from the browser. In those setups, a table without a policy can be readable by anyone.

RLS is one layer of protection, not the only one. Apps still need proper sign-in, server-side checks and careful handling of admin access.

Examples

  • Clients in a portal see only their own documents
  • Each team in a tool sees only its own projects

Questions

Do I need row-level security?

If your app stores private data for many users and any part of it queries the database directly from the browser, yes. If all access goes through a backend that checks permissions, RLS is an extra safety net.

Is row-level security the same as roles?

No. Roles describe what kind of user someone is, such as admin or member. Row-level security uses facts like the user's id or role to decide which specific rows they can reach.

Related terms

  • Authentication
  • Postgres
  • Database
  • Client portal

Read next

  • How to add role-based access control
  • Security checklist for AI-built apps

All terms · Build an app free