Prerendering dynamic routes
A dynamic route can be prerendered at build time for the parameter values
you already know. Export a generateStaticParams function from the route's
page file and return an array of parameter objects:
// app/blog/[slug]/page.tsx
export function generateStaticParams() {
return [{ slug: 'hello-world' }, { slug: 'second-post' }];
}
export default async function Page({ params }: { params: Promise<{ slug: string }> }) {
const { slug } = await params;
// ...
}
Each entry produces one prerendered URL, so /blog/hello-world and
/blog/second-post ship as static HTML.
With Cache Components, any dynamic URL not listed by
generateStaticParams is still served instantly — as the reusable App Shell
— and is then upgraded in the background with its now-known params and cached
for the next visitor. That background upgrade is Incremental Static
Regeneration (ISR).
So generateStaticParams decides which URLs are known at build time, and ISR
fills in the rest on demand.
You are about to answer a short quiz on generateStaticParams and ISR.