#makes sense so will go with joulev
1 messages ยท Page 1 of 1 (latest)
ok it seems that only works in classic API routes. Will try to extract the session from the auth headers.
Nope that works well with app router for me. What error occurs if you do that?
I am trying to do that on a server component. but when I console.log the session object it is null...
can u give me a little code snippet on how you use it with app router?
page.tsx
const session = await getServerSession(authOptions);
const columnData = getKnowledgeGroupedByColumn({
user: session?.user as JWT,
});
This is what I am trying to do in server component.
https://github.com/maxswjeon/blog
This is my blog that I am working on. I used NextAuth here, so you can check it. All admin routes in (admin)/admin are using getServerSession from server components
you have nextauth route in app folder interesting.
can u direct my where you use getServerSession in a server component like page.tsx ?
ok in admin page.
thx. Ill check! Thx for the input ๐ Will get back if I have questions ๐
Yup!
u think I might have to move [..nextauth] to app directory?
I dont know well, but I think you don't need to do it.
yeah dont think either... lets see!
where do you inject the sesssion in the session provider on client side?
I never injected session provider, because I never needed it.
RSC removed my need for SessionProvider
hmmmm mysterious ๐
Error: [next-auth]: useSession must be wrapped in a <SessionProvider />
Ah yes I never used useSession() at all
You see, all the session related work is done on the server side.
and then you prop drill it into the components needed or simply have a app wide state that u use?
I prop drill it until the first client component, and when I use the first client component, I pass the prop to the Provider to createContext of it.
ok. hmmm that would include major refactoring with my project. Thinking if I will simply revert to client side fetching for now...
especially since for some reason (I guess nextauth in pages) getServerSideSession keeps returning null...
Yup... If you are doing a refactoring a project, it might a big project
Hmmm... Did you checked cookies and logged if the callbacks are called?
well I will try to get it session object from auth cookies as last try to fetch user specific data on server side. Otherwise its gonna be client side fetching for now...
I think that will be complicated... Is the code sharable? May I see it too?
well I do that in route handlers atm as well.
guess all connected to having next-auth in pages.
Hmm... that's sad... Wish you solve it well
hehe thx for your compassion ๐ค
Hey are you online? Where did you call getServerSession?
in page.tsx