Next.js Discord

Discord Forum

Using getToken() in a page (App Router)

Unanswered
Saltwater Crocodile posted this in #help-forum
Open in Discord
Saltwater CrocodileOP
I'm trying to use getToken() in a page, but I'm missing the NextRequest that I'm supposed to pass in.

I previously used getServerSession(), but this only gave me the default session and does not have values returned from my session callback.

In getServerSession(handler), I passed in my NextAuth() function from api/auth/[...nextauth]/route.ts, but trying to pass that in to getToken like getToken(handler) or getToken({ req: handler }) won't work.

Is there a way to do this, or just a better alternative for my use-case where I need my full session data rendered on the server?

0 Replies