Skip to content

docs: fix incorrect SessionProvider placement in v5 migration guide#13459

Open
Magnuti wants to merge 1 commit into
nextauthjs:mainfrom
Magnuti:fix/docs-sessionprovider-migration-example
Open

docs: fix incorrect SessionProvider placement in v5 migration guide#13459
Magnuti wants to merge 1 commit into
nextauthjs:mainfrom
Magnuti:fix/docs-sessionprovider-migration-example

Conversation

@Magnuti

@Magnuti Magnuti commented Jun 24, 2026

Copy link
Copy Markdown

The "Client Component (App)" example in migrating-to-v5.mdx calls useSession() and then renders <SessionProvider> as a child of that same component.

useSession() reads context from an ancestor SessionProvider, so this throws [next-auth]: useSession must be wrapped in a <SessionProvider /> at runtime. It also contradicts the explanatory text right above the snippet.

This PR splits the example into the client component (just useSession()) and a root layout that wraps it with SessionProvider, matching the correct pattern already shown in docs/pages/getting-started/session-management/get-session.mdx.

The Client Component example called useSession() and then rendered
SessionProvider as a descendant of the same component. Since
useSession() reads context from an ancestor provider, this throws
"useSession must be wrapped in a <SessionProvider />" and contradicts
the explanatory text above it. SessionProvider now wraps the tree from
a parent layout, consistent with the pattern shown in
session-management/get-session.mdx.
@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
auth-docs Ready Ready Preview, Comment Jun 24, 2026 1:00pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
next-auth-docs Ignored Ignored Preview Jun 24, 2026 1:00pm

Request Review

@vercel

vercel Bot commented Jun 24, 2026

Copy link
Copy Markdown

@Magnuti is attempting to deploy a commit to the authjs Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant