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