NextAuth: How Session Object Get's Passed Between Pages?

Viewed 8

so I am going through and learning Next Auth as I plan to utilize it for my bigger project. When getting into it, there was a part that was not extremely intuitive to me and when looking for explanations people just sort of ignored explaining it in detail.

So I understand that as of the most recent version of Next Auth, we must wrap our highest level component inside of SessionProvider to allow the 'session' object to be passed through the components, I am just not sure HOW this is happening.

I have provided screenshots below as well. I am just not sure how it is that our SessionProvider allows us to pass the session object across components. I know the rule of thumb is that if you wrap your top component in SessionProvider, then any component that uses useSession() will be able to pass session across pages.

useSession being called inside of a Next component which returns to use the session object and status enum

SessionProvider wrapping our highest order component and taking in session as a prop

0 Answers
Related