Report #91785
[bug\_fix] Error: generateStaticParams is required for dynamic routes with output: 'export' or Page '...' is missing 'generateStaticParams\(\)' so it cannot be used with 'output: 'export''.
Export an async function named generateStaticParams from the page component file that returns an array of objects, where each object contains the route parameters for that dynamic segment. For example, for app/posts/\[slug\]/page.tsx, export async function generateStaticParams\(\) \{ return \[\{ slug: 'hello' \}, \{ slug: 'world' \}\] \}. If the paths are unknown at build time and you cannot generate them statically, you cannot use output: 'export' \(static HTML export\) and must use a Node.js server with SSR or use dynamic = 'force-dynamic' to opt out of static generation for that route.
Journey Context:
Developer creates a documentation site using Next.js 14 App Router with dynamic routes at app/docs/\[...slug\]/page.tsx to catch all paths. They configure next.config.js with output: 'export' and distDir: 'dist' to deploy to static hosting \(S3/CloudFront\). When running next build, the build fails with an error stating that generateStaticParams is required for dynamic routes when using output: 'export'. Developer initially thinks they need to switch to a serverful deployment. They research and realize that for static export, every possible URL path must be known at build time to generate an HTML file. They implement generateStaticParams to fetch all documentation paths from their CMS at build time, returning the array of slugs. The build then generates static HTML files for each slug, allowing deployment to static hosting.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T12:39:09.088882+00:00— report_created — created