Remix and Supabase Authentication
How to secure a Remix and Supabase application using Row Level Security
December 9th, 2021
December 9th, 2021
TL;DR: Source and Demo
Here's a live demo
Link to the source code
Link to step by step commits
This blog will focus on securing our Remix application with Supabase's Row Level Security (RLS) feature. If you want to know the context of what application I'm talking about, you can refer to my another blog.
Instead of updating my database from the previous blog, I'm just going to re-create it.
user_id
user_id
pointing to auth.users
createCookieSessionStorage
to help in managing our Supabase token/auth
route Since I'm too lazy to implement a login page, I'll just use the UI provided by Supabase.
@supabase/ui
You can create your custom sign-up and sign-in form if you want.
After logging in, the user will be redirected to the /words
route.
If you want to test without signing up, use the following credentials:
email: dev.codegino@gmail.com
password: testing
I don't want to pollute my other route, so I will create my signout action handler separately
loader
or action
NOTE: Conditional server-side rendering might cause hydration warning,
I'll fix this in another blog post.
The examples below are a longer version of using our setup for CRUD operations.
We can still use Supabase only on the client-side as we use it on a typical React application. However, putting the data fetching on the server-side will allow us to benefit from a typical SSR application.