Ship-Ready / Guides

Your form says "success". Your Supabase table is empty.

This is almost always a failed insert that nobody checked. supabase-js doesn't throw on a database error, it returns { error }. If your code ignores it, the success toast shows anyway. Here's how to find the real error, fix it without opening your table to the world, and check the fix.

Step 1: see the real error

Open DevTools → Network, submit the form, and click the request to /rest/v1/your_table. Or log it in code:

const { error } = await supabase.from("waitlist").insert({ email });
if (error) { console.error(error); /* show a failure, not a success toast */ }

No request at all usually means your Supabase URL or key env vars are missing in production. Add them in your host and redeploy.

Step 2: match the error

new row violates row-level security policy ... RLS is on and no INSERT policy allows this role
permission denied for table waitlist ........... the role (anon/authenticated) has no grant on the table
(insert works only without .select()) .......... .insert().select() also needs SELECT on the table

All three come back as code 42501, so read the message, not just the code.

Step 3: the wrong fixes (what AI tools often suggest)

When you paste the error into an AI assistant, it often proposes one of these. Each one makes the error go away and opens a hole:

alter table waitlist disable row level security;      -- anyone with your anon key can read the whole list
create policy ... for all using (true) with check (true); -- same, plus edit and delete
grant all on waitlist to anon;                          -- plus a wide policy = public emails

Your anon key ships inside your frontend on purpose. If the table can be read with it, your waitlist emails are public.

Step 4: the right fix

Public form (waitlist, contact): let anon insert, and nothing else.

grant insert on public.waitlist to anon;
create policy "anon can join waitlist" on public.waitlist
  for insert to anon with check (true);
-- no select policy for anon: nobody can read the list from the browser

Then call .insert({ email }) without .select(). If you add .select(), Postgres has to let anon read the new row, and you'd need a SELECT grant and policy you don't want. Read the list from the dashboard or a server route using the secret key.

Logged-in user creating their own rows: tie the row to the user.

grant insert, select on public.notes to authenticated;
create policy "insert own" on public.notes for insert to authenticated
  with check (auth.uid() = user_id);
create policy "read own" on public.notes for select to authenticated
  using (auth.uid() = user_id);

Step 5: check it the way an attacker would

Log out (or use a private window) and try to read the table with only the anon key:

curl "https://YOUR-PROJECT.supabase.co/rest/v1/waitlist?select=*" \
  -H "apikey: YOUR_ANON_KEY"

You want [], even though the table now has rows. For per-user tables, also run the second-user test: user B must not see user A's notes.

Want this checked for every table?

The free Ship-Ready quick scan runs locally and flags RLS-off tables, using (true) policies and exposed keys in your migrations. The Crew (59-check scan, $39) adds paste-ready fix prompts for each finding.

Related: is my anon key a problem? · test RLS as a second user · the 10-minute Supabase self-check