<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ATAYERO CLINTON</title>
    <description>The latest articles on DEV Community by ATAYERO CLINTON (@atayeroclinton).</description>
    <link>https://dev.to/atayeroclinton</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1349950%2Fa460c97d-8912-46a5-8159-c624d8bc7bd2.jpg</url>
      <title>DEV Community: ATAYERO CLINTON</title>
      <link>https://dev.to/atayeroclinton</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/atayeroclinton"/>
    <language>en</language>
    <item>
      <title>How I Built Multi-User Apps with Row-Level Security in Supabase</title>
      <dc:creator>ATAYERO CLINTON</dc:creator>
      <pubDate>Wed, 03 Jun 2026 17:05:31 +0000</pubDate>
      <link>https://dev.to/atayeroclinton/how-i-built-multi-user-apps-with-row-level-security-in-supabase-51o0</link>
      <guid>https://dev.to/atayeroclinton/how-i-built-multi-user-apps-with-row-level-security-in-supabase-51o0</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;&lt;em&gt;Originally published on &lt;a href="https://www.clintech.me/blog/building-multi-user-apps-with-rls" rel="noopener noreferrer"&gt;clintech.me&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When you move from toy projects to real products, the hard problem &lt;br&gt;
isn't styling cards. It's isolation: how do you make sure each user &lt;br&gt;
only sees their own data?&lt;/p&gt;

&lt;p&gt;The wrong answer: filter by &lt;code&gt;userId&lt;/code&gt; in React and hope no one cheats.&lt;br&gt;&lt;br&gt;
The right answer: Row-Level Security.&lt;/p&gt;
&lt;h2&gt;
  
  
  What RLS actually is
&lt;/h2&gt;

&lt;p&gt;RLS is a Postgres feature that enforces access policies at the database &lt;br&gt;
level — not the application level. Every query runs through your &lt;br&gt;
policies before returning data.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;CREATE&lt;/span&gt; &lt;span class="n"&gt;POLICY&lt;/span&gt; &lt;span class="nv"&gt;"Users can see their own jobs"&lt;/span&gt;
&lt;span class="k"&gt;ON&lt;/span&gt; &lt;span class="n"&gt;jobs&lt;/span&gt; &lt;span class="k"&gt;FOR&lt;/span&gt; &lt;span class="k"&gt;SELECT&lt;/span&gt;
&lt;span class="k"&gt;USING&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;uid&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this in place, even if someone opens DevTools and calls the &lt;br&gt;
Supabase REST API directly with a valid token, they still only get rows &lt;br&gt;
where &lt;code&gt;user_id&lt;/code&gt; matches their own auth UID. The database is the &lt;br&gt;
security gate, not your frontend.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I applied this in ApplyCraft
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://apply-craft.vercel.app" rel="noopener noreferrer"&gt;ApplyCraft&lt;/a&gt; is an AI-powered job &lt;br&gt;
tracker I built. Every job, note, and profile is scoped per user. &lt;br&gt;
The policy pattern is consistent across all tables:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;jobs.user_id = auth.uid()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;job_notes.user_id = auth.uid()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;profiles.id = auth.uid()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Even the server-side AI endpoint, which writes outreach copy back &lt;br&gt;
to a job row, verifies ownership before touching the database. &lt;br&gt;
No client-side key exposure, no trust in the frontend.&lt;/p&gt;

&lt;h2&gt;
  
  
  The mistakes that will burn you
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Enabling RLS but leaving "allow all" policies&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
You've technically turned it on but effectively disabled it. &lt;br&gt;
Every policy needs to be explicit.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Forgetting write policies&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
Easy to add &lt;code&gt;SELECT&lt;/code&gt; and forget &lt;code&gt;INSERT&lt;/code&gt;, &lt;code&gt;UPDATE&lt;/code&gt;, &lt;code&gt;DELETE&lt;/code&gt;. &lt;br&gt;
Your app will silently fail on writes and you'll spend an hour &lt;br&gt;
wondering why.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Trusting only frontend filters&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
If a table has unrestricted &lt;code&gt;SELECT&lt;/code&gt;, any user can bypass your &lt;br&gt;
UI and call the REST endpoint directly. RLS removes that &lt;br&gt;
possibility entirely.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Not following the ownership chain on joins&lt;/strong&gt;&lt;br&gt;&lt;br&gt;
If &lt;code&gt;notes&lt;/code&gt; belongs to &lt;code&gt;jobs&lt;/code&gt; and &lt;code&gt;jobs&lt;/code&gt; belongs to a user, your &lt;br&gt;
note policies should check ownership through that chain, not &lt;br&gt;
just assume the foreign key is enough.&lt;/p&gt;




&lt;p&gt;The difference between "multi-user UI" and "multi-tenant product" &lt;br&gt;
is where security lives. Once the database enforces it, your &lt;br&gt;
frontend gets simpler and your app gets much harder to abuse.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;I'm a frontend engineer open to remote EU roles, connect with &lt;br&gt;
me on &lt;a href="https://www.linkedin.com/in/clinton-atayero-3800b5238/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; &lt;br&gt;
if this was useful.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>supabase</category>
      <category>react</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
