Given the Next.js route configuration and a dynamic path, what will the component render?
export const dynamicParams = false; export function generateStaticParams() { return [{ slug: 'hello' }, { slug: 'world' }]; } export default function Page({ params }) { return <p>Slug is: {params.slug}</p>; }
Consider how generateStaticParams and dynamicParams affect static generation and matching.
With dynamicParams = false, Next.js only matches paths returned by generateStaticParams. So only /hello and /world render the component with correct slug. Other paths 404.
Choose the correct way to disable dynamic route matching in a Next.js route segment config.
Check the official Next.js config option for dynamic route control.
The correct config to disable dynamic route matching is dynamicParams = false. Other options are invalid and cause errors or are ignored.
Given this catch-all route and config, what will be the output for path /docs/intro/getting-started?
export const dynamicParams = true; export default function Page({ params }) { return <p>Docs path: {params.slug.join(' > ')}</p>; }
Remember how catch-all routes pass params as arrays and how dynamicParams affects matching.
Catch-all routes pass the matched segments as an array in params.slug. With dynamicParams true, the route matches any path under /docs, so the output joins the segments with ' > '.
Analyze the code and config below. Why does the route show 404 for path /product/123?
export const dynamicParams = false; export function generateStaticParams() { return [{ id: '456' }]; } export default function Page({ params }) { return <p>Product ID: {params.id}</p>; }
Check the interaction between dynamicParams and generateStaticParams.
With dynamicParams = false, Next.js only serves paths returned by generateStaticParams. Since '123' is not in the list, it 404s.
Explain the matching behavior of Next.js routes when dynamicParams = false and generateStaticParams returns multiple paths. Which paths are served and which cause 404?
Think about static generation and disabling dynamic routes.
When dynamicParams is false, Next.js disables dynamic route matching and only serves the exact paths returned by generateStaticParams. Any other path returns 404.