© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•13mo ago•
3 replies
jmac

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
supabase.auth.getUser()
supabase.auth.getUser()
on every page using
useEffect()
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
layout.tsx
using
@supabase/ssr
@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?
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Client side user
SupabaseSSupabase / help-and-questions
3y ago
Best way to get authenticated user on client side
SupabaseSSupabase / help-and-questions
13mo ago
NextJS: User data client side?
SupabaseSSupabase / help-and-questions
2y ago
Server side auth via the supabase React client
SupabaseSSupabase / help-and-questions
4y ago