/
githubmirror
/
next.js
Обзор
Документация
Войти
/
githubmirror
/
next.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
canary
errors/generate-static-params.mdx
44 строки
2 KB
Jiwon Choi
Throw for empty or incomplete generateStaticParams results with output: export (#95969)
24 июл 2026, 00:25
Не верифицирован
24 июл 2026, 00:25
f2e6abb
Код
Авторство
О чём код?
--- title: '`generateStaticParams` Error' --- ## Why This Error Occurred Next.js expects `generateStaticParams` to return an array containing one params object for each route to generate. This error occurs when: - `generateStaticParams` returns 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, and `undefined`. ## Possible Ways to Fix It Return an array of params objects from `generateStaticParams`: ```tsx filename="app/blog/[slug]/page.tsx" export function generateStaticParams() { return [{ slug: 'first-post' }, { slug: 'second-post' }] } ``` See the [`generateStaticParams` return value documentation](/docs/app/api-reference/functions/generate-static-params#returns) for the expected shape. ## Using `output: 'export'` When your application uses `output: 'export'`, every [Dynamic Route](/docs/app/api-reference/file-conventions/dynamic-routes), 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 `generateStaticParams` function, - returns an empty array from `generateStaticParams`, or - generates a route without every dynamic route parameter. For example, `{ slug: 'first' }` does not provide the `id` value 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. ## Useful Links - [`generateStaticParams` documentation](/docs/app/api-reference/functions/generate-static-params) - [Static Exports documentation](/docs/app/guides/static-exports) - [Dynamic Routes documentation](/docs/app/api-reference/file-conventions/dynamic-routes)