Functions
generateStaticParams
Generates path parameter objects for dynamic segments during a build. Each object supplies matching segment names. With Cache Components enabled, a defined generateStaticParams must return at least one sample for validation; omit the function for runtime-only params and provide appropriate Suspense handling. ISR does not rerun this function. This example uses a finite public catalog. Source: https://nextjs.org/docs/app/api-reference/functions/generate-static-params. Documentation-reviewed illustrative draft; installed declarations and runtime not verified.
Formal Syntax & Structure
nextjs syntaxnextjs
export function generateStaticParams() { return [{ slug: "moss" }]; }Working Example
Example Snippetnextjs
import { notFound } from "next/navigation";const articles = new Map([["moss", "Moss care"], ["fern", "Fern care"]]);export function generateStaticParams() { return Array.from(articles.keys(), slug => ({ slug }));}export default async function Article({ params }: { params: Promise<{ slug: string }> }) { const title = articles.get((await params).slug); if (!title) notFound(); return <h1>{title}</h1>;}