#makes sense so will go with joulev

1 messages ยท Page 1 of 1 (latest)

uncut juniper
#

ok it seems that only works in classic API routes. Will try to extract the session from the auth headers.

long cave
#

Nope that works well with app router for me. What error occurs if you do that?

uncut juniper
#

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.

long cave
uncut juniper
#

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.

long cave
uncut juniper
#

thx. Ill check! Thx for the input ๐Ÿ™ Will get back if I have questions ๐Ÿ˜…

long cave
#

Yup!

uncut juniper
#

u think I might have to move [..nextauth] to app directory?

long cave
#

I dont know well, but I think you don't need to do it.

uncut juniper
#

yeah dont think either... lets see!

#

where do you inject the sesssion in the session provider on client side?

long cave
#

I never injected session provider, because I never needed it.

#

RSC removed my need for SessionProvider

uncut juniper
#

hmmmm mysterious ๐Ÿ˜…

#

Error: [next-auth]: useSession must be wrapped in a <SessionProvider />

long cave
#

Ah yes I never used useSession() at all

#

You see, all the session related work is done on the server side.

uncut juniper
#

and then you prop drill it into the components needed or simply have a app wide state that u use?

long cave
#

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.

uncut juniper
#

especially since for some reason (I guess nextauth in pages) getServerSideSession keeps returning null...

long cave
#

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?

uncut juniper
#

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...

long cave
#

I think that will be complicated... Is the code sharable? May I see it too?

uncut juniper
#

well I do that in route handlers atm as well.

#

guess all connected to having next-auth in pages.

long cave
#

Hmm... that's sad... Wish you solve it well

uncut juniper
#

hehe thx for your compassion ๐Ÿค—

long cave
#

Hey are you online? Where did you call getServerSession?

uncut juniper
#

in page.tsx