simple getServerSideProps doesn't working

314 Views Asked by At

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>
    )
} 
1

There are 1 best solutions below

0
On

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.