generateStaticParams
A function exported from a dynamic route that lists the param values to pre-render as static pages at build time.
In more detail
next build calls it and renders one static page per returned object, such as [{ slug: 'a' }, { slug: 'b' }]. Values not in the list are rendered on demand, or return a 404 if dynamicParams is false.
Example
export async function generateStaticParams() {
return (await getPosts()).map((p) => ({ slug: p.slug }));
}Related terms
- dynamic route — A route whose folder name is in square brackets, such as [slug], so one page file serves many URLs.
- dynamicParams — A route segment option that decides what happens to dynamic param values not returned by generateStaticParams.
- static rendering — Rendering a page to HTML once, at build time or on a schedule, and serving that same result to every visitor.
Taught in
- Templates vs Layouts: Remounting & Page Transitions — Next.js 15 & Modern App Router Architecture
- Dynamic Routes: Slugs & generateStaticParams — Next.js 15 & Modern App Router Architecture