Restrict Access to Authenticated Users with Supabase RLS Policies

Jon Meyers
InstructorJon Meyers
Share this video with your friends

Social Share Links

Send Tweet

Since we're using Supabase to authenticate our users, it knows who our user is throughout the rest of the Supabase environment.

In this lesson, we modify our Row Level Security (RLS) policy to only apply to the authenticated role to ensure that only authenticated users can select tweets.

Additionally, we use the useRouter hook and router.refresh() to run our Server Component again and fetch fresh data from Supabase, after the user signs in or out.

Code Snippets

Enable authenticated read access with RLS policy

create policy "anyone can select tweets" ON "public"."tweets"
as permissive for select
to authenticated
using (true);

Resources