Report #4607
[bug\_fix] Page /\[slug\] is missing generateStaticParams\(\) so it cannot be used with output: 'export' or Error: Dynamic server usage: searchParams
Export an async function named generateStaticParams from the dynamic route segment file. This function must return an array of objects where each object defines the concrete values for the dynamic segments \(e.g., \[\{ slug: 'hello' \}, \{ slug: 'world' \}\]\). For static export, every possible path must be enumerated at build time. Root cause: When output: 'export' is set, Next.js generates static HTML at build time and cannot handle dynamic path segments that aren't explicitly defined; the router needs the complete path manifest to generate the folder structure \(e.g., out/\[slug\]/index.html\).
Journey Context:
Developer configures next.config.js with output: 'export' and distDir: 'dist' to deploy to a static host. They have a dynamic route at app/blog/\[slug\]/page.tsx that fetches post data. Running next build throws an error stating the page is missing generateStaticParams and cannot be used with static export. Developer initially tries to hardcode return \[\{ slug: 'test' \}\] just to pass the build, but realizes this only generates one page. They then refactor generateStaticParams to fetch the full list of slugs from their headless CMS or file system at build time, returning the complete array. After this, the build succeeds and generates static HTML files for every blog post in the out/blog/\[slug\]/ directories.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T19:46:39.419116+00:00— report_created — created