Files
vercel__next.js/errors/generate-static-params.mdx
T
Jiwon Choi 81643544fc Throw when generateStaticParams returns invalid values (#95968)
> [!TIP]
> This PR is best reviewed commit by commit.

### Why?

`generateStaticParams` must return an array of objects, but Next.js does
not currently provide a clear error when it returns something else.

### How?

- Throw when `generateStaticParams` does not return an array.
- Throw when an item in the returned array is not an object.
- Keep allowing `{}`. The follow-up rejects it with `output: 'export'`
when it leaves a dynamic route parameter missing.

Follow-up: #95969

Supersedes #95388.

<!-- NEXT_JS_LLM -->

Co-authored-by: SukkaW <isukkaw@gmail.com>

---------

Co-authored-by: Joseph <joseph.chamochumbi@vercel.com>
2026-07-23 23:25:55 +02:00

29 lines
920 B
Plaintext

---
title: 'Invalid `generateStaticParams` Value'
---
## 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.
## Useful Links
- [`generateStaticParams` documentation](/docs/app/api-reference/functions/generate-static-params)