useSession seems to reset post hydration #3879
Unanswered
nilskaspersson
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have an application with unknown dynamic pages that I protect using the new middleware
withAuth
. After acquiring a JWT and accessing the app, the following happens:When Next.js is configured to use the
"blocking"
fallback method for the dynamic pages,useSession().status
goes throughloading
toauthenticated
and remains persistent. All good.However when I use
fallback: true
, the behavior changes; the immediate initialization goes through the same, but whenuseRouter().isFallback
shifts fromtrue
tofalse
, the session is seemingly flushed, goes throughloading
again, but results inunauthenticated
—no request ever goes out to/api/auth/session
for this second loading state. Forcing a revalidation throughrefetchOnWindowFocus
immediately triggers a session request and sets the status toauthenticated
again.I would hope for the behavior to be the same regardless of fallback mode.
I can't shake the feeling that I have misconfigured something, but I cannot find anything in the docs or example implementation that is strikingly different.
Am I going about something all wrong? Any insight is appreciated!
Beta Was this translation helpful? Give feedback.
All reactions