Short answer
An empty array without an error almost always means row level security filtered out every row. RLS does not raise an error on select; rows the user may not see simply do not exist for that request. The usual causes are no select policy, a policy that checks the wrong column, rows that belong to another user, or a signed-out request. Missing grants are different: they give error 42501, not an empty array. Fix it with a select policy tied to the owner, never with using (true).
Ask an AI about this page:ChatGPTClaude
On this page
When row level security is on, every select gets the table’s policies added as an invisible filter. Rows the current user may not see are not an error, they are simply left out. If the filter removes everything, supabase-js gets an empty list and no error. Postgres’s docs put it plainly: with RLS on and no policy that applies, no rows are visible. So data: [] with error: null usually means “your policies hide these rows from this user”, not “the table is empty”.
const { data, error } = await supabase.from("notes").select("*");
// data: [], error: nullFind your cause in 30 seconds
| What you see | Most likely cause |
|---|---|
| The table has insert policies but none for select | No select policy |
| A select policy exists, still nothing | The policy checks the wrong column |
| Some rows show, the ones you expect do not | The rows belong to someone else |
| Empty right after page load or on a public page | The request is signed out |
| Empty in the SQL editor too | There really is no data |
We reproduced each cause on Postgres with Supabase’s roles, on this table:
create table public.notes (
id uuid primary key default gen_random_uuid(),
user_id uuid not null default auth.uid() references auth.users (id) on delete cascade,
body text not null,
created_at timestamptz not null default now()
);
alter table public.notes enable row level security;The five causes
1. RLS is on and there is no select policy
With RLS on, everything is hidden until a policy allows it. Many generated migrations add an insert policy so that saving works, and forget select. The insert succeeds, the list stays empty. A table with RLS on and no policies at all behaves the same, which the fix for RLS without policies covers.
2. The policy checks the wrong column
A select policy exists but never matches. A frequent slip is comparing the user to the row’s own id instead of its owner column:
create policy "Users can read their notes"
on public.notes for select
to authenticated
using ((select auth.uid()) = id);id is the note’s id, which is never the user’s id, so no row ever matches. The same happens when the policy uses created_by but the app fills user_id, or when the policy is written for anon while the app is signed in.
3. The rows belong to someone else
The policy is right, but the rows were not created by this user. Typical cases: test data inserted in the Table Editor with another account’s id, rows from before you added sign-in, or a filter such as .eq("id", idFromUrl) that points at another user’s row. The policy correctly hides them. If the code used .single(), the same situation shows up as JSON object requested, multiple (or no) rows returned instead.
4. The request is signed out
Without a session, the request runs as anon and auth.uid() is null. A policy for authenticated does not apply to anon at all, so the result is empty. This happens when a query runs before supabase-js has restored the session after a page load. Check what the client really sends:
const { data: { session } } = await supabase.auth.getSession();
console.log(session ? `signed in as ${session.user.id}` : "signed out");5. There really is no data
If the table is empty in the SQL editor too, RLS is not the problem. Check that the app’s VITE_SUPABASE_URL points at the same project you are looking at in the dashboard. A preview build talking to a second project is a common surprise.
Empty array or error 42501?
Since Supabase’s 2026 change, new tables get no grants for the API roles. That gives a different symptom: an error with code 42501 and permission denied for table, not an empty array. Writes have their own version too: an insert blocked by RLS fails with new row violates row-level security policy. An empty array on select means the role may use the table, and the policies or the data are the reason.
How to fix it
Add one select policy that lets each user read their own rows, for signed-in users only:
drop policy if exists "Users can read their notes" on public.notes;
create policy "Users can read their notes"
on public.notes for select
to authenticated
using ((select auth.uid()) = user_id);The (select auth.uid()) form is what Supabase recommends: Postgres computes it once per query instead of once per row. If several users share rows, for example in a team, the policy checks membership instead of a single owner. The RLS policy builder writes both variants, and the Supabase RLS guide explains when to use which.
create policy "Anyone can read notes"
on public.notes for select
using (true);My Supabase query returns data: [] and error: null for the table your_table, but the rows exist. Find the table’s migrations, its row level security policies and the code that reads it. Tell me which of these applies: no select policy, a policy that compares auth.uid() with the wrong column, rows whose owner column holds another user’s id, or a query that runs before the user is signed in.
Then fix it: in a new migration, add a select policy for the authenticated role only, with using ((select auth.uid()) = the owner column). In the app, make sure the query only runs after the session is restored. Do not add policies with using (true), do not disable row level security, do not use the service role key in client code and do not edit existing migrations. Show me the migration and the code change before applying them.
Check that the fix works
In the SQL Editor, count the rows twice: once as the owner of the table, once as a signed-in user. Use a real user id from Authentication → Users:
select count(*) as all_rows from public.notes;
begin;
set local role authenticated;
set local request.jwt.claims = '{"sub": "11111111-1111-1111-1111-111111111111", "role": "authenticated"}';
select count(*) as rows_for_this_user from public.notes;
rollback;If all_rows is above zero and rows_for_this_user is zero, RLS is filtering, and the cause is one of the first four. If both are zero, there is no data. To see which policies the table has for reading:
select policyname, roles, qual
from pg_policies
where schemaname = 'public'
and tablename = 'notes'
and cmd in ('SELECT', 'ALL');After the fix, rows_for_this_user equals the number of that user’s notes. Run the count once more with another user’s id: it must not include the first user’s notes. The guide to testing RLS policies has more checks to run before launch.
Frequently asked questions
Why is there no error when RLS blocks my select?
Because for reads, a policy works like an invisible where clause. Rows the user may not see are left out, and an empty result is a valid answer. Only writes that break a policy raise an error.
The rows show up in the Table Editor. Why not in my app?
The Table Editor and the SQL editor run as the postgres role, which owns the table and is not subject to RLS. Your app runs as anon or authenticated. Compare both counts as shown under Check that the fix works.
Could the 2026 change to new tables cause an empty array?
No. A table without grants for the API roles fails with permission denied for table and code 42501. If you get an empty array, the role is allowed to use the table and the policies, or the data, are the reason.
Should I turn off RLS to see if that is the problem?
Do not turn it off on a live project, even for a minute: during that time anyone with your anon key can read the whole table. Use the check on this page instead, which reads the table as the user inside a transaction and changes nothing.
Sources
- 1.Why is my select returning an empty data array and I have data in the table? — Supabase Docs
- 2.Row Level Security — Supabase Docs
- 3.Row Security Policies — PostgreSQL Documentation
- 4.Database API 42501 errors — Supabase Docs
- 5.JavaScript: Fetch data — Supabase Docs