Next.js Discord

Discord Forum

So confused about middleware and passing in auth (with supabase)

Unanswered
Savannah posted this in #help-forum
Open in Discord
SavannahOP
I'm using supabase and trying to pass the user object from the middleware into the pages so i can have the pages decide what to do depending on whether a user is logged in or not. What is the canonical way to do this? I would rather have a parameter passed in that represents some request object and be able to append fields to it like "user" which can be undefined/null if the user is not logged in and the user object if they are

Middleware that can't pass the objects through kind of makes no sense to me - as it seems that I would be checking for authentication TWICE... Once in the middleware and once on the page??

0 Replies