Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible issue in the migration-to-v5 guide #12767

Open
kossidts opened this issue Mar 12, 2025 · 0 comments
Open

Possible issue in the migration-to-v5 guide #12767

kossidts opened this issue Mar 12, 2025 · 0 comments
Labels
triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.

Comments

@kossidts
Copy link

What is the improvement or update you wish to see?

Hello, maybe I am missing something but shouldn't a (context) provider be at least one layer/level above the consumer?

Looking at migrating-to-v5 the section (Step 4 Details -> Client component (App)) does not look right.

 'use client';
 
 import { useSession, SessionProvider } from 'next-auth/react';
 
 const ClientComponent = () => {
   const session = useSession();
 
   return (
     <SessionProvider>
       <p>Welcome {session?.user?.name}</p>
     </SessionProvider>
   )
 }

Is there any context that might help us understand?

I think it should be something like the following instead.

import { SessionProvider } from 'next-auth/react';
import { ClientComponent } from '@/components';
 
 const ParentComponent = () => {
 
   return (
     <SessionProvider>
       <ClientComponent />
     </SessionProvider>
   )
 }
'use client';
 
 import { useSession } from 'next-auth/react';
 
 const ClientComponent = () => {
   const session = useSession();
 
   return (
       <p>Welcome {session?.user?.name}</p>
   )
 }```

### Does the docs page already exist? Please link to it.

https://authjs.dev/getting-started/migrating-to-v5
@kossidts kossidts added the triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime. label Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Unseen or unconfirmed by a maintainer yet. Provide extra information in the meantime.
Projects
None yet
Development

No branches or pull requests

1 participant