'TypeError: Cannot convert undefined or null to object next.js

Error -

TypeError: Cannot convert undefined or null to object

This error happened while generating the page. Any console logs will be displayed in the terminal window.

Code -

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

function login({ providers }) {
  return (
    <div>
    <img className='w-52 mb-5' src='https://links.papareact.com/9xl' alt=''/>
    {Object.values(providers).map((provider) => (
      <div>
        <button>Login with {provider.name}</button>
      </div>
    ))}
    </div>
  );
}

export default login

export async function getServerSideProps() {
  const providers = await getProviders();

  return {
    props: {
      providers,
    },
  };  
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source