Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between useSession and getSession in next-auth?

What's the difference between useSession and getSession in next-auth? Both seems to be returning session object.

like image 262
Ishan Bassi Avatar asked Feb 25 '26 03:02

Ishan Bassi


1 Answers

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

like image 152
Chemi Adel Avatar answered Feb 27 '26 04:02

Chemi Adel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!