-1

I'm trying to use getServerSideProps nextJS function but it just doesn't work. Just return undefined for my props...


export async function GetServerSideProps(context){
    var test = 3 
    return {
        props: {
            test
        }
    }
}
 
export default function Page(props){

    console.log(props.test)

    return (
        <div>
           {props.test}
        </div>
    )
} 
Renato
  • 121
  • 1
  • 8

1 Answers1

0

You have a typo in your function name: GetServerSideProps ==> getServerSideProps. getServerSideProps function name needs to be camel cased, otherwise it's not picked up and executed by Next.js.

juliomalves
  • 42,130
  • 20
  • 150
  • 146