How to store auth.user information on the client side
I am using Next.js (App Router) with Supabase authentication. Right now, I am fetching
Would it be better to fetch the authenticated user in
What is the best practice for managing authentication efficiently in a scalable Next.js app? Should I store user data in middleware (seems wrong), Context, or fetch it in each component?
supabase.auth.getUser() on every page using useEffect(), but this seems inefficient. Calling the database for user information on every route?Would it be better to fetch the authenticated user in
layout.tsx using @supabase/ssr and pass it to a global state. Does anyone have any examples of how they have done this?What is the best practice for managing authentication efficiently in a scalable Next.js app? Should I store user data in middleware (seems wrong), Context, or fetch it in each component?