Server-side vs client-side authentication with Next-auth (caching) #63858
Unanswered
codinginflow
asked this question in
App Router
Replies: 1 comment 2 replies
-
I guess so, because,
https://nextjs.org/docs/app/api-reference/functions/cookies
|
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I need some clarification here.
Let's say I want to display the currently logged-in user in the navbar.
If I fetch the session server-side (
getServerSession
or now justawait auth()
in v5), all pages that display this navbar are dynamically rendered. There is no way to statically cache them anymore, correct?Considering this, would it make sense to move the session retrieval client-side, if I want to enable static caching? This would be done by wrapping the layout into a
SessionProvider
, not passing asession
prop, and then retrieving the session viauseSession
inside the navbar.Am I missing something? Like another better option? Or any caveats about my approach?
Beta Was this translation helpful? Give feedback.
All reactions