| title | `generateStaticParams` Error |
|---|
Next.js expects generateStaticParams to return an array containing one params object for each route to generate.
This error occurs when:
generateStaticParamsreturns a value that is not an array, or- an item in the returned array is not a plain object. This includes
null, arrays, primitive values, andundefined.
Return an array of params objects from generateStaticParams:
export function generateStaticParams() {
return [{ slug: 'first-post' }, { slug: 'second-post' }]
}See the generateStaticParams return value documentation for the expected shape.
When your application uses output: 'export', every Dynamic Route, such as app/blog/[slug]/page.tsx, must be rendered at build time.
This error also occurs when a dynamic route:
- does not export a
generateStaticParamsfunction, - returns an empty array from
generateStaticParams, or - generates a route without every dynamic route parameter. For example,
{ slug: 'first' }does not provide theidvalue for a route using an[id]segment.
When multiple route segments export generateStaticParams, Next.js combines the params returned by each parent and child function before generating routes.
Export generateStaticParams from every dynamic route and make sure the combined params include all dynamic route parameters for every generated route. If the paths cannot be known at build time, remove output: 'export' from your Next.js configuration.