What's the difference between useSession
and getSession
in next-auth
? Both seems to be returning session
object.
Difference between useSession and getSession in next-auth?
For a more complete answer: #77094115 –
Rep
useSession
ReactJS hook that works only on client, that returns states which helps you to update UI and it's made on top of getSession
getSession
async function that read current cookies and returns session, works both on Client and Server
And what about
getSession
vs getServerSession
? –
Embowed @RobinvanBaalen you can protect server side rendered pages using the getServerSession method. This is different from the old getSession() method, in that it does not do an extra fetch out over the internet to confirm data from itself, increasing performance significantly. You need to add this to every server rendered page you want to protect. Be aware, getServerSession takes slightly different arguments than the method it is replacing, getSession. Check this link –
Dahabeah
For a more complete answer: #77094115 –
Rep
© 2022 - 2024 — McMap. All rights reserved.