---
title: Empty generateStaticParams with Cache Components
url: "https://nextjs.org/docs/messages/empty-generate-static-params"
docs_index: /docs/llms.txt
---



## Why This Error Occurred

You're using [Cache Components](https://nextjs.org/docs/app/getting-started/caching) in your Next.js application, and one of your `generateStaticParams` functions returned an empty array, which causes a build error.

When Cache Components is enabled, Next.js performs build-time validation to ensure your routes can be properly prerendered without runtime dynamic access errors. If `generateStaticParams` returns an empty array, Next.js cannot validate that your route won't access dynamic values (like `await cookies()`, `await headers()`, or `await searchParams`) at runtime, which would cause errors.

This strict requirement ensures:

- Build-time validation catches potential runtime errors early
- All routes using Cache Components have at least one static variant to validate against
- You don't accidentally deploy routes that will fail at runtime

## Possible Ways to Fix It

Return at least one real parameter when your data source has entries. If your data source is empty at build time, use a [placeholder parameter](#option-2-use-a-placeholder-param) and handle it with `notFound()`.

### Option 1: Return at least one static param

Modify your `generateStaticParams` function to return at least one set of parameters. This is the most common fix and allows build-time validation to work properly.

```tsx filename="app/blog/[slug]/page.tsx"
// This will cause an error with Cache Components
export async function generateStaticParams() {
  return [] // Empty array not allowed
}

// Return at least one sample param
export async function generateStaticParams() {
  return [{ slug: 'hello-world' }, { slug: 'getting-started' }]
}
```

These samples serve dual purposes:

1. **Build-time validation**: Verify your route structure is safe
2. **Prerendering**: Generate instant-loading pages for popular routes

The build process only validates code paths that execute with your sample params. If runtime parameters trigger conditional logic that renders branches accessing runtime APIs (like `cookies()`) without Suspense, or dynamic content without Suspense or `use cache`, those will cause runtime errors.

### Option 2: Use a placeholder param

If your CMS, database, or API can have no entries at build time, return a placeholder parameter when the list is empty. Handle that value with `notFound()` in your page so the build can complete without a real entry. Return real parameters whenever entries are available:

```tsx filename="app/blog/[slug]/page.tsx"
import { notFound } from 'next/navigation'
import { getPost, getPosts } from '@/lib/posts'

export async function generateStaticParams() {
  const posts = await getPosts()

  if (posts.length === 0) {
    return [{ slug: '__placeholder__' }]
  }

  return posts.map((post) => ({ slug: post.slug }))
}

export default async function Page({
  params,
}: {
  params: Promise<{ slug: string }>
}) {
  const { slug } = await params

  // The placeholder renders the not-found UI.
  if (slug === '__placeholder__') {
    notFound()
  }

  const post = await getPost(slug)

  if (!post) {
    notFound()
  }

  return <div>{post.title}</div>
}
```

The placeholder only validates the code path that calls `notFound()`. Code that loads and renders real content remains unvalidated when the data source is empty. Ensure those code paths handle dynamic data with Suspense or `use cache`, as appropriate, to avoid runtime errors when real parameters are requested.

## Useful Links

- [Cache Components Documentation](https://nextjs.org/docs/app/getting-started/caching)
- [generateStaticParams API Reference](https://nextjs.org/docs/app/api-reference/functions/generate-static-params)
- [Dynamic Routes with Cache Components](/docs/app/api-reference/file-conventions/dynamic-routes#with-cache-components)
