Next.js Discord

Discord Forum

How to get session

Unanswered
American black bear posted this in #help-forum
Open in Discord
American black bearOP
Hello, how can i get data session from /api/auth/session without spamming the website and the token will changed anytime?

20 Replies

that the issue
if im trying to use "useSession" that will end the app
like
spamming error
@American black bear spamming error
What do you have in [...nextauth]
@goodsie What do you have in [...nextauth]
American black bearOP
route.ts but i fixed by :
    callbacks: {
      async jwt({ token, account, profile }) {
        if (account) {
          token.accessToken = account.access_token
          token.id = profile.id
        }
        return token
      }
    },

But i have other problem when im use "pages" on next-auth to "/login" so i get 'Missing "code_verifier"'
like
pages: {
  'signIn': '/login'
}
You are using pages router method?
@goodsie You are using pages router method?
American black bearOP
App router method
I did this for callbacks:
  callbacks: {
    async jwt({ token, user }) {
      if (user) token.user = user;
      return token;
    },

    async session({ session, token }) {
      session.user = token.user;
      session.tier = token.tier;
      return session
    }
  },
:lolsob:
🤣
American black bearOP
let me fix about the "pages" because im keeping get 404 (i hate this)
@American black bear like ts pages: { 'signIn': '/login' }
American black bearOP
this im mean
American black bearOP
@goodsie if im making App router login how im add to link about the state?