---
title: "`generateStaticParams` Error"
url: "https://nextjs.org/docs/messages/generate-static-params"
docs_index: /docs/llms.txt
---



## 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.

## With `ensureStatic`

A dynamic route that uses [`ensureStatic = 'navigation'`](/docs/app/api-reference/file-conventions/route-segment-config/ensureStatic#navigation) must export `generateStaticParams` and return at least one params object. Every object must include a value for each dynamic segment in the route.

```tsx filename="app/blog/[slug]/page.tsx"
export const ensureStatic = 'navigation'

export function generateStaticParams() {
  return [{ slug: 'first-post' }, { slug: 'second-post' }]
}
```

If the route must accept values that cannot be listed at build time, first confirm that request-time rendering is intended for the entire route. Then remove `ensureStatic = 'navigation'` from every page or layout that sets it. Removing the export relaxes the static-output requirement for every segment in the route.

## 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)
