SessionProvider missing in app router
I've got a t3 project using next 14 with next-auth and the "new" app router. It was created yesterday (Mar-19-2024).
According to the docs (next-auth page):
In your app’s entrypoint, you’ll see that your application is wrapped in a SessionProvider.However, I don't see any
<SessionProvider>
in my app router project. And I'm pretty sure it is used in pages router t3 projects.
Is this intentional? I do believe I'm getting or trying something wrong. Maybe I should avoid using useSession()
?
Or is it ok if I wrap my application with a <SessionProvider> in ./src/app/layout.tsx
?
Every comment is appreciated and I'm sure other noobs will be curious about that too!1 Reply
while using the app router you are supposed to use the RFCs to fetch the user on the server and pass the required data to Client Components.
But if you want to use "useSession" just add the session provider that'll work ig
one problem I was facing w the new way of app router is that my session was expiring wayyy too soon if you have a solution for that pls let me know