Report #10123
[bug\_fix] Page with dynamic route is missing generateStaticParams\(\) so it cannot be used with output: 'export'
Export an async function named generateStaticParams from the dynamic route page file that returns an array of param objects \(e.g., \[\{ slug: 'post-1' \}, \{ slug: 'post-2' \}\]\). Root cause: output: 'export' generates purely static HTML at build time with no Node.js server to handle dynamic requests; therefore, every possible dynamic path must be enumerated during the build so Next.js can generate the corresponding HTML files.
Journey Context:
Developer configures next.config.js with output: 'export' and distDir: 'dist' to deploy to a static host. They create a dynamic route at app/posts/\[slug\]/page.tsx that fetches post data based on params.slug. Running next build fails with: 'Page /posts/\[slug\] is missing generateStaticParams\(\) so it cannot be used with output: export'. Developer searches the error and finds that for static export, dynamic routes must implement generateStaticParams to tell Next.js which pages to generate at build time. They implement the async function to fetch all possible slugs from their CMS and return them as an array of objects. After this, the build succeeds and outputs /posts/hello-world/index.html etc.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T09:51:12.749480+00:00— report_created — created