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

110
Vistas
not able to receive data in providers

I am trying to make a login page using nextjs and spotify js but encountering following error

error encoutered

Below is the following code

import React from 'react'
import { getProviders , signIn } from "next-auth/react"

function Login({ providers }) {
    return (
        <div>
           

            {Object.keys(providers).map((provider) => {
                <button>Login With {provider.name}</button>
            })}
        </div>
    )
}

export default Login;


export async function getServerSideProps() {
    const providers = await getProviders()
    
    return {
        props : {
            providers,
        }
    }
}

AND below is the code for providers in [...nextauth].js

export default NextAuth({
    // Configure one or more authentication providers
    providers: [
        SpotifyProvider({
            clientId: process.env.NEXT_PUBLIC_CLIENT_ID,
            clientSecret: process.env.NEXT_PUBLIC_CLIENT_SECRET,
            authorization: LOGIN_URL,
        }),
        // ...add more providers here
    ],
})


       
about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

How I see it:

import React from 'react'
import { getProviders , signIn } from "next-auth/react"

function Login({ providers }) {
    return (
        <div>
           

            {providers.map((provider) => {
                <button>Login With {provider.name}</button>
            })}
        </div>
    )
}

export default Login;


export async function getServerSideProps() {
    const providers = await getProviders()
    //check if you have some data here
    console.log(providers)

    return {
        props : {
            providers: providers,
        }
    }
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

Make sure your nextjs api pointed to current hosting URL. For example : http://localhost:3000. Otherwise it will not work!

about 4 years ago · Juan Pablo Isaza Denunciar

0

I'm guessing that either you didn't get any providers or your providers object is undefined on initial render. You can use Object.keys(providers || {}) instead to make sure it's always an object.

Also, Object.keys returns a string array of keys on the object meaning that the provider will be a string and won't have a name property. If you're iterating over the Object.keys you would need to use providers[provider].name instead of provider.name

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