NextJs Error - You can not use getInitialProps with getStaticProps. To use SSG, please remove your getInitialProps
This error was widely noticed when codebase gets upgraded to React 18 / latest versions of Nextjs.
If you are using newer versions of Nextjs , then it is better to use getStaticProps instead of getInitialProps .
Do not mix both together , either use getStaticProps or getInitialProps .
getStaticProps - when used on page leads to static site generation (SSG)
getServerSideProps - when used on page leads to server side rendering (SSR) & only available on page components .
You might also encounter other errors when using nextjs:
Comments
Post a Comment
Oof!