Skip to content

Auth Session Starts Authenticated #12367

Answered by LDrex1
boopxyz asked this question in Help
Dec 10, 2024 · 3 comments · 10 replies
Discussion options

You must be logged in to vote

Hmm yeah you're right.
So these console logs are from initial navigation to a page / route? Without the user touching any login / log out button?
Where is your <SessionProvider /> in the component tree? Root layout?

Important

Using the latest version of Next.js v14 (not v15) with the app router

Correct, it's from the start of loading a page. My SessionProvider is in a client component (given I'm using the app router) which is in the layout

<Providers session={getSession()} />

which equals

<SessionProvider session={session}>{children}</SessionProvider>

This doesn't look right.

Why don't you pass it this way from your async layout component or whereever

const session = await getServerSe…

Replies: 3 comments 10 replies

Comment options

You must be logged in to vote
9 replies
@nic-vo
Comment options

@boopxyz
Comment options

@nic-vo
Comment options

@LDrex1
Comment options

Answer selected by boopxyz
Comment options

You must be logged in to vote
1 reply
@boopxyz
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
3 participants