Closed mmarrius closed 3 weeks ago
Hey yeah so there's a hard split between where you should use auth()
and where you shuold use getSession
/useSession
.
auth()
is the new "all-in-one" method that works everywhere server-side (i.e. in server components as well).getSession
/useSession
as before. They're imported from next-auth/react
and of course useSession
still requires the components to be wrapped in the SessionProvider
, right.We recommend grabbing your session in the nearest server-component and passing it down via props to a client-component though, instead of using those client methods, if possible.
If theres any specific improvements you'd like to see, feel free to open a PR and we can talk about it more there :pray:
Otherwise, i'll close this issue for now
What is the improvement or update you wish to see?
Use auth() instead of getServerSession, getSession, withAuth, getToken, and useSession
is found here but thengetSession
is nowhere else on the page described. Shouldauth()
be used instead of it? If yes, why isn't it included in the list of examples?Is there any context that might help us understand?
getSession
is the bread and butter in v4 but is sparsely mentioned in v5. Should it still be used?Does the docs page already exist? Please link to it.
https://authjs.dev/getting-started/migrating-to-v5