Report #94441
[bug\_fix] Missing generateStaticParams for Dynamic Route in Next.js App Router SSG
Export an async function \`generateStaticParams\` from the dynamic route page file that returns an array of objects containing the route parameters. Alternatively, add \`export const dynamic = 'force-dynamic'\` to opt into dynamic rendering at request time.
Journey Context:
Developer creates \`app/posts/\[slug\]/page.tsx\` to render blog posts. The component fetches data based on \`params.slug\`. During \`next build\`, the process fails with an error: 'generateStaticParams is required for dynamic route /posts/\[slug\]'. Developer realizes that by default, Next.js App Router attempts to statically generate all pages at build time. For dynamic segments like \`\[slug\]\`, Next.js cannot guess which slugs exist. Developer implements \`export async function generateStaticParams\(\) \{ const posts = await fetchPosts\(\); return posts.map\(p => \(\{ slug: p.slug \}\)\); \}\` in the page file. Build succeeds, generating static HTML for each returned slug.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T17:06:19.443645+00:00— report_created — created