Next.js Discord

Discord Forum

Generating pages statically - App Router

Answered
Leafcutting bee posted this in #help-forum
Open in Discord
Leafcutting beeOP
Hi all, having a bit of trouble wrapping my head around static page generation using the app router.

### Dynamic Routes
I understand that in a app/[slug]/page.tsx file I can include a generateStaticParams function, this should return an array like [{slug: "slug1"}, {slug: "slug2"}]. My confusion is where I should do my data fetching for this. Should I still do my data fetching within the server component or should I do my data fetching in my generateStaticParams function and have a content property on each object in the array?

### Non-dynamic routes
How would I get my app/page.tsx page to statically render? Do I still need to return an array of slugs from the generateStaticParams function?

Sorry if I've missed anything obvious, thanks for reading.
Answered by joulev
dynamic pages != dynamic param pages.

dynamic param pages that are statically generated (via generateStaticParams) are still static pages
View full answer

12 Replies

@Leafcutting bee Awesome, thank you! Is there any way to configure a revalidation time in the App router?
export const revalidate = 10 if you want to revalidate every 10 seconds
@joulev `export const revalidate = 10` if you want to revalidate every 10 seconds
Leafcutting beeOP
Thank you so much
@joulev `export const revalidate = 10` if you want to revalidate every 10 seconds
Leafcutting beeOP
Sorry, this is for both dynamic and non-dynamic?
@Leafcutting bee Sorry, this is for both dynamic and non-dynamic?
only for static pages. dynamic pages always revalidate. in fact export const revalidate = 0 is a valid way to make a dynamic page for something that would otherwise be a static page
I'm basically trying to get ISR behaviour on all my dynamic and non-dynamic routes
@Leafcutting bee Oh this is confusing, so a dynamic page will revalidate every time a user visits it?
dynamic pages != dynamic param pages.

dynamic param pages that are statically generated (via generateStaticParams) are still static pages
Answer
that's what i meant
there are two different meanings of "dynamic" here
Leafcutting beeOP
Ahh ok thank you, yeah, got myself confused