Guides

Supabase query returns an empty array and no error? It’s Row Level Security

By Fixplain. Updated 16 Nov 2026. Supabase, PostgreSQL, Security.

Error message: data: [], error: null

You can see the rows in the Supabase Table Editor, but your app gets data: [] and error: null. Nothing is broken: Row Level Security (RLS) is doing its job.

Why this happens

When RLS is enabled on a table and no policy allows a row, Postgres doesn't throw an error. It just filters that row out. With no policies at all, every row is filtered, so you get an empty list.

The Table Editor shows the rows because the dashboard uses a privileged role that bypasses RLS. Your app uses the anon key, or the authenticated role once someone is signed in, and those roles only see what policies allow.

Fix: add a policy for what you actually want

For a typical "each user sees their own rows" table:

-- read your own rows
create policy "Read own todos"
on public.todos for select
to authenticated
using ((select auth.uid()) = user_id);

-- create rows only for yourself
create policy "Insert own todos"
on public.todos for insert
to authenticated
with check ((select auth.uid()) = user_id);

using decides which existing rows are visible. with check decides which new or changed rows are allowed. If an insert fails with "new row violates row-level security policy", you're missing the with check part, or user_id isn't being set to the signed-in user.

For data that really is public, like a list of products:

create policy "Anyone can read products"
on public.products for select
to anon, authenticated
using (true);

Still empty? Check who the query runs as

  • On the server (Server Components, route handlers), the Supabase client only knows the user if you pass the request's cookies, for example with @supabase/ssr's createServerClient. Without them, the query runs as anon and auth.uid() is null.
  • Wrong column. user_id must actually contain the user's id from auth.users.
  • Test it in SQL by pretending to be a user inside a transaction:
begin;
set local role authenticated;
set local request.jwt.claims = '{"sub":"PUT-A-USER-UUID-HERE"}';
select * from public.todos;
rollback;

Don't "fix" it with the service role key

The service role key bypasses RLS completely. It belongs only in server code and environment variables. Never put it in a file that runs in the browser, and never in a variable starting with NEXT_PUBLIC_. If it has ever been exposed, rotate it in Settings → API.