© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•3y ago•
6 replies
megatz

Next Js 14 RLS only for authenticated user not working

I was following through @jonmeyers videos up to https://egghead.io/lessons/next-js-restrict-access-to-authenticated-users-with-supabase-rls-policies .

Before I applied the user.id = auth.uid() expression check in my policy, I just tried to enabling the RLS and refreshed my localhost. Unexpectedly, my data is still visible to all users.

Tried setting the expression check to true and still the same thing but when i tried false instead, it worked as expected (only unauthenticated users can see). That was the exact opposite of what my project needs.

I followed through the video from start up to the RLS section carefully and the auth-helpers using Google provider is working just fine. Sessions are stored in cookies but I am wondering why only the false logic is working and not the true.

I don't think this because my project is built using Next JS 14. Is it my middleware.ts? or I need to manually set conditions if(sessions) to return those data in my page.tsx from getSession(). I tried clearing caches but issues still remain

Hopefully anyone can help me resolve this.
Thank you in advance.
image.png
image.png
image.png
egghead
Expert led courses for front-end web developers.
expert led courses for front-end web developers and teams that want to level up through straightforward and concise lessons on the most useful tools available.
Expert led courses for front-end web developers.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

Next.js, user doesn't get authenticated
SupabaseSSupabase / help-and-questions
4y ago
Next.js SSR RLS
SupabaseSSupabase / help-and-questions
13mo ago
User not authenticated ERROR
SupabaseSSupabase / help-and-questions
2mo ago
RLS without being authenticated
SupabaseSSupabase / help-and-questions
4y ago