DEV Community

Kazutora Hattori
Kazutora Hattori

Posted on

The story of how RLS was the cause of data retrieval issues in Supabase [React x Supabase]

Introduction

When I was building a map app using React and Supabase,
I was troubled by the browser console displaying "Data fetched: Array(0)" and no pins appearing, even though data was already in Supabase.

As it turns out, the cause was RLS (Row Level Security).

Symptom

Data exists in the Supabase table.

However, executing select('*') in React returns Array(0).

No error occurs (i.e., communication was successful).

What I tried

Checked the URL and Anon key in .env.

Checked the spelling of the table and column names.

Confirmed the existence of data in the Supabase console.

Still couldn't retrieve the data.

Cause: RLS (Row Level Security)

In Supabase, RLS may be automatically enabled for newly created tables.

When RLS is enabled, only authenticated users can read the data.

Solution

Supabase → "Table Editor" → Open the target table

Check "Enable RLS" in the top menu.

If it's blue (enabled), click it to disable (gray).

Now, you can retrieve data even with anonymous access.
The message Data fetched: [ {...} ] appears, and you can add a pin to the map.

Summary

If Supabase reports "empty data" and no errors,
first check whether RLS is enabled.

Top comments (0)