Report #63116
[bug\_fix] Page is missing "generateStaticParams\(\)" so it cannot be used with "output: export" or dynamic routes return 404 in static build.
Export an async function named \`generateStaticParams\` from the dynamic route's page.tsx \(or layout.tsx\) that returns an array of param objects. For a route \`app/blog/\[slug\]/page.tsx\`, return \`\[\{ slug: 'post-1' \}, \{ slug: 'post-2' \}\]\`. For dynamic data, fetch the list of valid params inside this function.
Journey Context:
Developer creates a blog using Next.js 13 App Router. Creates \`app/blog/\[slug\]/page.tsx\` that fetches post data based on \`params.slug\`. In development \(\`next dev\`\), visiting \`/blog/hello-world\` works perfectly, fetches data, renders page. Developer runs \`next build\` with \`output: 'export'\` to generate static files for CDN deployment. Build fails with error: "Error: Page is missing generateStaticParams\(\) so it cannot be used with output: export." Developer confused because it worked in dev. Realizes that for static export, Next.js must pre-render all possible dynamic paths at build time; unlike dev which handles dynamic routes on-the-fly. Implements \`export async function generateStaticParams\(\) \{ const posts = await getAllPosts\(\); return posts.map\(post => \(\{ slug: post.slug \}\)\); \}\` in the page file. Build now generates \`blog/post-1.html\`, \`blog/post-2.html\`, etc. Why fix works: generateStaticParams provides the exhaustive enumeration of route parameters that the static site generator needs to create physical HTML files for each dynamic segment variant.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T12:25:17.944556+00:00— report_created — created