Skip to main content

Type error: 'GetServerSideProps' refers to a value, but is being used as a type here. Did you mean 'typeof GetServerSideProps'


Type error: 'GetServerSideProps' refers to a value, but is being used as a type here. Did you mean 'typeof GetServerSideProps'

This error occurs when you use imported "GetServerSideProps" server side props function .

"GetServerSideProps" is the typescript type of "getServerSideProps".


To fix the error :

If you are using javascript then just remove the import GetServerSideProps from "next" and then change the server side function to:


export const getServersideProps = async () => {


  return { props: { oof: "hello" } };


};



If codebase is typescript based then use "GetServerSideProps" as the type and modify the function to :


export const getServerSideProps: GetServerSideProps = async () => {

  return { props: { oof: "hello" } };


};




You might also encounter other errors when using the getServerSideProps :

Comments

Topics

Show more