T3App session not set

Spun a new app with AppRouter, NextAuth, TRPC and prisma with sqlite, have added my discord auth and can confirm working (can see session in db). However session is still undefined and have no idea why. I can technically fix it by adding SessionProvider but I dont think this is the right choice when using AppRouter. Thanks!
4 Replies
rocawear
rocawear4d ago
you mean session is undefined on clientside or on server? if you want to obtain it clientside you need sessionprovider serverside you just call
const session = await auth()
const session = await auth()
Chemist
ChemistOP4d ago
both actually, the session callback never got called but afaik when using app router I can just call const session = await auth() no?
rocawear
rocawear4d ago
when calling from server component but on client component you need to use useSession() hook
Chemist
ChemistOP4d ago
i think src/app/page.tsx is a server component?

Did you find this page helpful?