Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

117
Views
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 answers
Answer question

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 Report

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!