Back to TIL
March 2026
posted on 03.29.2026

Next.js dynamicParams and NoFallbackError

In Next.js, setting dynamicParams = false on a page with generateStaticParams() tells the framework to return a hard error for any path not pre-generated at build time. This is not a 404. It is an unhandled NoFallbackError that spams server logs.

// This CRASHES on unknown slugs — even from bots/crawlers
export const dynamicParams = false

export async function generateStaticParams() {
  return posts.map(p => ({ slug: p.slug }))
}
// This gracefully falls through to notFound()
export const dynamicParams = true

export default async function Page({ params }) {
  const post = posts.find(p => p.slug === params.slug)
  if (!post) notFound() // proper 404
}

With dynamicParams = false, every crawler hitting /blog/nonexistent-slug throws NoFallbackError in the server logs. In production with Docker Swarm, this can make the service appear unhealthy if the error rate is high enough.

The fix is dynamicParams = true combined with explicit notFound() calls in the page component. You still get static generation for known slugs via generateStaticParams(), but unknown slugs get a clean 404 instead of a crash.

No reactions yet

in Naperville, IL
Last visitor from Mitaka, Japan
⌘K