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

Taught in

References