Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

Next.js 16+ · Const

dynamicParams

dynamicParams controls requests for dynamic route segments that generateStaticParams did not generate. It defaults to true for request-time generation; false makes those paths return 404.

How it works

Export this route-segment setting from a layout, page, or route to decide how dynamic paths missing from generateStaticParams behave. Keep the default true to generate such paths at request time, or use false to make them return a 404.

Syntax

export const dynamicParams = true // true | false

Parameters

NameTypeDescription
dynamicParamsbooleanA boolean route-segment setting: true enables request-time generation for omitted paths, while false makes omitted paths return 404.

Key points

  • Use this segment configuration to choose the behavior for a dynamic URL that was not generated ahead of time.
  • The default permits additional dynamic paths to be created when users request them.
  • Set the option to false when only the paths returned by generateStaticParams should be valid.

Common mistakes

  • Do not export this setting when Cache Components is enabled; the configuration is unsupported.
  • In the App Router, use dynamicParams instead of the Pages Router's getStaticPaths fallback modes.

Example: Allow only generated blog paths

// app/blog/[slug]/page.tsx
export const dynamicParams = false

export function generateStaticParams() {
  return [{ slug: "hello-world" }]
}

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

Only the slug returned by generateStaticParams is served; another slug receives a 404.

When to use it

Reject ungenerated paths

A product or documentation site should serve only a known catalog of generated slugs.

Generate paths on demand

A route should support new parameter values beyond the build-time list.

Replace fallback modes

Migrating an application from the Pages Router's getStaticPaths fallback behavior.

Interview questions

QWhat does dynamicParams control?

It controls requests for dynamic segments that generateStaticParams did not return. true, the default, generates those segments at request time; false returns a 404.

Follow-up: How would you prevent runtime generation while retaining a successful response for unknown data? Keep dynamicParams true and handle missing data with notFound() in the page.

QWhere is dynamicParams declared?

Export dynamicParams as a boolean from a page, layout, or route segment. Its value applies to dynamic segments not included in generateStaticParams.

Follow-up: What happens when Cache Components is enabled? The export is unsupported and should be removed; use notFound() when a parameter does not resolve to real data.

QWhat is the difference between true and false?

The default true allows omitted dynamic paths to be generated on demand. Setting it to false restricts serving to generated paths and makes omitted paths return 404.

Follow-up: Which older routing API did this replace? It replaces getStaticPaths fallback modes from the Pages Router.

  • generateStaticParams
  • dynamic
  • getStaticPaths
  • Cache Components
  • dynamic segments

Source: dynamicParams - Route Segment Config. Checked 2026-10-15.