"new row violates row-level security policy": why data won't save in Supabase
A user fills in a form, presses Save, and nothing happens. The console or logs show "new row violates row-level security policy for table", followed by the table name. A public example: new row violates row-level security policy for table "players_secure" ( supabase/postgres #1708 ). Row-level security (RLS) is a set of rules on each table about who may read or write which rows. Supabase says…
When a user submits a form and clicks "Save", the data fails to be saved to the database. The error message displayed is "new row violates row-level security policy for table". Row-level security (RLS) consists of rules governing which rows a user can access for reading or writing. After enabling RLS, no data is accessible through the API using a publishable key until policies are created.
The database enforces the table's security by aborting the entire INSERT command if the inserted row does not meet the policy requirements. To resolve this issue, a policy must be added that grants the appropriate permissions for the user or role attempting to write the row. Without a proper policy, the database will prevent the row from being saved.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.