Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

330
Vistas
Nextjs plus nextauth cannot configure jwt

I am trying to setup JWT with NextAuth and it's just being a pain, reading through posts on GitHub, and researching is returning no help. I have a feeling it's some error happening when NextAuth attempts to decode the JWT payload, I am just trying to return a string of numbers that are returned from Twitch upon signin, I need this to use in a API call to Twitch.

I am new to JWT and NextAuth so I am no pro!

github repo for entire project https://github.com/MatWebsites/next-auth-example-main

Any help would be huge!

// console errors
unhandledRejection: TypeError: Cannot read properties of undefined (reading 'next-auth.session-token')
-
error - Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.
-
TypeError: getCurves is not a function
-

nextjs error page error

//[...nextauth].js
import NextAuth from "next-auth"
import Providers from "next-auth/providers"

export default NextAuth({
  providers: [
    Providers.Twitch({
      clientId: process.env.TWITCH_CLIENT_ID,
      clientSecret: process.env.TWITCH_CLIENT_SECRET,
    }),
    Providers.Spotify({
      clientId: process.env.SPOTIFY_CLIENT_ID,
      clientSecret: process.env.SPOTIFY_CLIENT_SECRET
    }),
  ],
  secret: process.env.SECRET,

  session: {
    jwt: true,
  },

  // https://next-auth.js.org/configuration/options#jwt
  jwt: {
    // A secret to use for key generation (you should set this explicitly)
     secret: process.env.SECRET,
    // Set to true to use encryption (default: false)
    // encryption: true,
    // You can define your own encode/decode functions for signing and encryption
    // if you want to override the default behaviour.
    // encode: async ({ secret, token, maxAge }) => {},
    // decode: async ({ secret, token, maxAge }) => {},
  },
  callbacks: {
     async signIn(user, account, profile) { return true },
    // async redirect(url, baseUrl) { return baseUrl },
     async session(session, user) { return session },
     async jwt(token, user, account, profile, isNewUser) { 
       token.accessToken = account.access_token;
       return token 
      }
  },
  theme: 'light',

  debug: true,
})
//test.js - trying to decode and use the data inside the web token
import { getToken } from 'next-auth/jwt'
const secret = process.env.SECRET

const test =  (req, res) => {
    const token = getToken({req, secret});
    return (
        <div>
            <a>{token.sub}</a> // Should show the users id returned from Twitch
        </div>
    )
}

export default test
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

getToken returns a promise. You have to await for it before doing any operation on it.

const test = async  (req, res) => {
    const token = await getToken({req, secret});
    return (
        <div>
            <a>{token.sub}</a> // Should show the users id returned from Twitch
        </div>
    )
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda