Next.js Discord

Discord Forum

Transition to Supabase Auth

Unanswered
Cuvier’s Dwarf Caiman posted this in #help-forum
Open in Discord
Cuvier’s Dwarf CaimanOP
Hello, I need insights about supabase auth best practice. Where should signin/signup be done? In client side or server-side? Im using Vite + React (Frontend) and Express + Prisma (Backend)

12 Replies

Haddock
Do sign-in/signup on the client using Supabase. your server should only verify the token and handle authorization and database logic.
@Haddock Do sign-in/signup on the client using Supabase. your server should only verify the token and handle authorization and database logic.
Cuvier’s Dwarf CaimanOP
Like auth check middleware right? How about the refresh token?
Haddock
yes, use server-side middleware to verify the access token only.
Refresh tokens stay on the client, supabase handles refreshing automatically
@Haddock Refresh tokens stay on the client, supabase handles refreshing automatically
Cuvier’s Dwarf CaimanOP
Thanks bro
@Cuvier’s Dwarf Caiman Thanks bro
Haddock
welcome
@Haddock welcome
Cuvier’s Dwarf CaimanOP
bro i have another question, if sign in are done in client-side, the session are saved in localstorage, right? So if someone stole my session (not yet expired) then it can make a request to my server because the access token will passed to validation middleware
@/* @__PURE__ */ alfonsus they are supposed to be saved in cookies
Cuvier’s Dwarf CaimanOP
So my approach is correct? That supabase auth should be done in server side and manually saved access and refresh token in http only cookie
you can still do sign in in client side and have session stored in cookies