Nextjs Fundamentals · App Router

Prerendering dynamic routes

`generateStaticParams` and ISR

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.

  1. The ___ function prerenders specific dynamic-route URLs at build time.
  2. `generateStaticParams` returns an array of parameter objects to prerender.
  3. With Cache Components, a dynamic URL not listed by `generateStaticParams` is served an App Shell and then upgraded in the background.
  4. The background upgrade-and-cache of an unknown dynamic URL is called Incremental Static ___.
  5. `generateStaticParams` runs in the browser for each visitor.