Next.js Discord

Discord Forum

what's the alternative of `getStaticProps` in next app router?

Unanswered
definitelynotshourya posted this in #help-forum
Open in Discord
went through the docs but found it confusing. Need to fetch data at build time only for certain pages(these pages though are dynamic, that is, have dynamic routes).

basically I have this:
I have a blogs page (example.com/blogs/) - currently is a async server side page. want to make it static page
I have the individual blogs pages (example.com/blogs/*) - these pages have links in the main blog page itself. want to make these static as well.

*by static, I meant to fetch data only once during the project build and later serve these pre bult pages.

4 Replies

Red carpenter ant
just fetch data inside the function as normally. it will be static by default
Siberian Flycatcher
@Siberian Flycatcher Hi 👋 Check out `generateStaticParams` https://nextjs.org/docs/app/api-reference/functions/generate-static-params
cool. one last thing: how do i check if the page is being served statically or is it being rendered in server side and then served?
Siberian Flycatcher
You can see statically generated pages in the build logs