Supabase returns an empty array [] but the table has data
Your Supabase query returns [] with no error even though rows exist? Row Level Security is on with no policy allowing the read.
Last edited October 18, 2026
On this page
What it means in plain English
Supabase has a safety system called Row Level Security (RLS). When it's on and no rule allows a user to see a row, Supabase doesn't throw an error, it just quietly returns nothing.
Supabase Launch Safety Pack
RLS checklist, policy templates, key migration and environment variable setup.
Secure checkout by Stripe
One-time payment through Stripe. Priced in USD. Local taxes such as UK VAT may be added at checkout.
Likely causes
- RLS is enabled on the table but no SELECT policy exists. Supabase docs: once RLS is enabled, no data is accessible via the API with a publishable key until you create policies.
- The policy only allows
authenticatedusers, but the visitor isn't signed in (or their session expired, soauth.uid()is null). - The policy compares
auth.uid()to auser_idcolumn that's empty or holds a different value.
How to fix it, step by step
- Supabase dashboard → Table Editor → select the table and check whether RLS is enabled and what policies exist (or Database → Policies).
- Decide who should see the rows:
- Public data (e.g. product list): add a SELECT policy for
anon, authenticatedwithusing (true). - Each user's own data: add a SELECT policy for
authenticatedwithusing ((select auth.uid()) = user_id).
- Public data (e.g. product list): add a SELECT policy for
- Example SQL (SQL Editor):
create policy "Users can view their own rows"
on public.todos for select
to authenticated
using ( (select auth.uid()) = user_id );
- Make sure rows actually have the correct
user_idfilled in when created. - Don't fix this by turning RLS off or by putting the secret/service_role key in the browser; that exposes all your data.
- Lovable/Bolt: you can ask "Add an RLS SELECT policy so signed-in users can read their own rows in
", then review the SQL before running it.
How to check it worked
- Reload the page while signed in; rows should appear.
- Sign in as a second user and confirm they can't see the first user's rows.
A reload that suddenly shows rows is the session case: Supabase data loads only after a refresh. An insert that fails only when you chain
.select()is insert works, .select() returns 42501. A broken image URL is Supabase Storage images not loading.Asking for one row with
.single()when the query is empty is a different response. See Supabase PGRST116: the result contains 0 rows.Sources
- https://supabase.com/docs/guides/database/postgres/row-level-security (opens in a new tab)
- https://supabase.com/docs/guides/api/securing-your-api (opens in a new tab)
- https://supabase.com/docs/guides/api/api-keys (opens in a new tab)
Related fixes
Tool to consider: Supabase.
Supabase Launch Safety Pack
RLS checklist, policy templates, key migration and environment variable setup.
Secure checkout by Stripe
One-time payment through Stripe. Priced in USD. Local taxes such as UK VAT may be added at checkout.