{
  "id": 16946774,
  "title": "3 Supabase RLS mistakes I keep seeing in real projects (and the fix for each)",
  "url": "https://urgent.news/2026/10/28/3-supabase-rls-mistakes-i-keep-seeing-in-real-projects-and-the-fix",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-28T19:38:42.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/chris_b/3-supabase-rls-mistakes-i-keep-seeing-in-real-projects-and-the-fix-for-each-5f34"
  },
  "original_language": "en",
  "account": "Row Level Security (RLS) plays a crucial role in safeguarding user data on Supabase. This article highlights three common mistakes encountered in real projects, along with their respective fixes.\n\nFirstly, RLS often remains disabled when tables are created using plain SQL. To enable RLS, execute the following command: `alter table notes enable row level security;`. Additionally, create a policy specifying the allowed actions for the owner: `create policy \"owner can read\" on notes for select using (auth.uid() = user_id);`.\n\nSecondly, views can inadvertently bypass RLS if proper measures are not taken. By default, a view runs with its owner's rights. To prevent potential data exposure, create the view with `security_invoker = true` (Postgres 15 and newer): `create view my_notes with (security_invoker = true) as select * from notes;`.\n\nLastly, policies should refrain from utilizing `user_metadata` when determining roles or permissions. User_metadata can be edited by users themselves, making it unsuitable for such purposes. Instead, leverage `app_metadata` or establish a dedicated roles table that is exclusively writable by your server. For additional RLS patterns, explore the comprehensive guide available at <https://getcodenest.com/products/supabase-rls-policy-cookbook>.",
  "summary": "Row Level Security (RLS) is what stands between your users and each other's data in Supabase. These are three mistakes that show up again and again, with the fix for each. 1. RLS was never enabled A table created with plain SQL has RLS switched off. Turn it on and add a policy: alter table notes enable row level security ; create policy \"owner can read\" on notes for select using ( auth . uid () =…",
  "key_points": [
    "RLS disabled when tables created via plain SQL",
    "Views can bypass RLS if not configured properly",
    "Policies must avoid using usermetadata for roles"
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}