COMPARISON · SUPABASE

Supabase RLS vs. SpiceDB: When Row Level Security Isn’t Enough

Supabase Row Level Security is one of the best ways to start securing an app: rules in SQL, enforced inside Postgres on every request. As products add teams inside teams, folders inside folders, sharing and AI features, those rules get harder to write, keep fast and reuse. That is where SpiceDB takes over.

Last reviewed November 2026. Try the interactive demo.

Short answer

For owner-only and simple team rules, Supabase RLS on its own is the right choice. Once access depends on relationships, such as nested teams, inherited folders, shares that expire, or the same rules in a search index, another service or an AI agent, SpiceDB is the stronger way to decide access. You can keep RLS as the enforcement layer: SpiceDB decides, a sync keeps an access table in Postgres current, and one short policy reads it.

What Supabase RLS does well

Supabase builds on Postgres Row Level Security. Each policy is attached to a table and runs every time the table is accessed, written in SQL, and combined with Supabase Auth for security from the browser to the database. It deserves its reputation:

Where RLS starts to strain

Real products rarely stop at “owners see their rows”. The demo walks one document app through seven requirements. The first two are easy for both approaches. Then:

What SpiceDB does better

SpiceDB is an open-source permissions database inspired by Google’s Zanzibar. It stores relationships, such as Lee is on Platform, Platform is part of Engineering or the API folder is inside Specs, and computes access from them.

Side by side

Supabase RLS aloneSpiceDB
Owner-only rulesOne line of SQLTwo lines of schema plus an API call
Nested teamsRecursive security definer functionOne relation
Inherited foldersRecursive walk per candidate rowOne arrow
Shares that expireShares table, expiry checks, cleanupBuilt in
Who can see this, and whyA second, mirrored queryLookupSubjects and explain
Search, other services, AI agentsRebuild the logic in eachSame API everywhere
ConsistencySame transaction, always currentPer-request choice with ZedTokens
Extra infrastructureNoneSpiceDB, self-hosted or managed

The verdict. SpiceDB is the better tool for deciding access once your rules are about relationships, and the only one of the two that serves systems outside Postgres. RLS remains the better tool for enforcing simple rules inside Postgres with no extra moving parts. Most growing products end up using both.

Using them together

  1. Write relationships to SpiceDB when people share documents, join teams or move folders, from your app or an Edge Function.
  2. Keep an access table in Postgres current with a sync driven by SpiceDB’s change stream.
  3. Read it with one short RLS policy, so the Data API, Realtime and pgvector stay protected inside the database.
  4. Call SpiceDB directly for writes, share dialogs, search filtering and AI retrieval.
create function private.my_document_ids()
returns setof uuid language sql stable
security definer set search_path = '' as $$
  select document_id from private.document_access
  where user_id = (select auth.uid());
$$;

create policy "Documents: read via SpiceDB" on documents
for select to authenticated
using ( id in (select private.my_document_ids()) );

For people who can see very many documents, filter with SpiceDB’s lookup results in the query or an Edge Function instead of a long access list, in line with Supabase’s performance guidance.

Frequently asked questions

Should I replace Supabase RLS with SpiceDB?

Not necessarily. Keep RLS for simple rules and as the enforcement layer inside Postgres. Add SpiceDB when access depends on relationships such as nested teams, inherited folders or sharing, or when systems outside Postgres need the same rules.

Is SpiceDB slower than RLS because it is a separate service?

For simple ownership checks, RLS has no network hop and is hard to beat. For relationship-heavy rules, SpiceDB caches graph traversals across requests and can precompute permissions, while recursive RLS policies run per candidate row on every query. Test both with your data.

Does SpiceDB work with Supabase Auth?

Yes. Use the Supabase Auth user ID, the value of auth.uid(), as the subject in SpiceDB checks, so both systems refer to the same person.

Does RLS protect pgvector searches for RAG?

Yes, when the vectors live in Postgres tables covered by your policies. An external vector database is not covered by RLS; SpiceDB’s LookupResources can filter it.

See both approaches side by side

The interactive demo builds one document app both ways through seven requirements, then lets you sign in as five people, nest teams, share folders and expire a contractor’s access.

Open the demo · Try the quickstart · Get a custom demo

SpiceDB Field Resources is maintained by AuthZed, the company that created SpiceDB. AuthZed and Supabase are independent companies; Supabase is a trademark of Supabase, Inc. Supabase details reflect its published documentation as of November 2026; corrections are welcome at info@tryspicedb.com.