Report #104580
[bug\_fix] Next.js App Router: 'params' is undefined in getStaticPaths or generateStaticParams when using dynamic routes
In App Router, use \`generateStaticParams\` instead of \`getStaticPaths\`. The function receives \`params\` directly as an argument, but you must ensure the function returns an array of objects with the correct param keys matching the folder structure \(e.g., \`\[\{ id: '1' \}, \{ id: '2' \}\]\` for \`\[id\]\` folder\).
Journey Context:
Developer migrating from Pages Router to App Router had a dynamic route \`app/blog/\[slug\]/page.js\`. They tried to use \`getStaticPaths\` as in Pages Router, but got an error that \`getStaticPaths\` is not a function. After reading the Next.js migration guide, they learned that App Router uses \`generateStaticParams\` exported from the page file. They rewrote the function, but initially forgot to return an array of objects with the \`slug\` key, causing the build to fail with 'params is undefined'. The fix was to ensure \`generateStaticParams\` returned \`\[\{ slug: 'post-1' \}, \{ slug: 'post-2' \}\]\`.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-09-06T20:07:50.864940+00:00— report_created — created