1

Im using nextJs for a while. Now initiating a new project using the app router (where traditional behavior is called the pages router). In the pages router, I could export getStaticProps to build pages on run time. Which is very ideal for data that doesn't vary often (e.g portfolio website ) From docs:

If you export a function called getStaticProps (Static Site Generation) from a page, 
Next.js will pre-render this page at build time using the props returned by getStaticProps.

When I export a getStaticProps in page.tsx file (app router). Im getting the following error:

"getStaticProps" is not supported in app/. 
Read more: https://nextjs.org/docs/app/building-your-application/data-fetching

Going to the docs page suggested in the error message left me extremely confused. It was talking about caching, when I want to generate a static page.

Is this behavior possible using the new app router? and if so how?

yoty66
  • 390
  • 2
  • 12

0 Answers0