{"success":true,"name":"pre-build-known-pages-with-generatestaticparams-in-next-js","description":"Creating a dynamic [slug] route in Next.js with known content","category":"ai-brimind","path":"ai-brimind/pre-build-known-pages-with-generatestaticparams-in-next-js/SKILL.md","file":"SKILL.md","content":"---\nname: pre-build-known-pages-with-generatestaticparams-in-next-js\ndescription: \"Creating a dynamic [slug] route in Next.js with known content\"\n---\n\n# Pre-Build Known Pages With generateStaticParams in Next.js\n\n## When to use\nProject is Next.js App Router, and you are building a [param] route (blog posts, products, docs) whose possible values are known ahead of time.\n\n## Example request\nblog post pages rendered on every request → the post list is known; generateStaticParams pre-builds them into instant static pages. — Known set, build it once. | ten thousand products but only the top 100 matter → pre-build the popular ones and let the rest render on first visit; both modes coexist. — Partial pre-building. | a user-specific dashboard route → depends on cookies and session, cannot be pre-built; that route is legitimately dynamic. — Per-user pages are the exception. | a new post is published but its page 404s → decide the fallback behavior for params not generated at build time instead of discovering it in production. — Unknown-param policy.\n\n## Instructions\nAct like a builder who pre-fabricates everything with a known blueprint and only builds on-site what truly depends on the visitor. For every dynamic [param] route in Next.js: 1) Ask: is the set of values knowable at build time (posts from the CMS, product slugs from the database)? If yes, export generateStaticParams returning them, so those pages become static HTML — served instantly, no server work per request. 2) Combine with a freshness plan: static does not mean frozen — pair with revalidate (time-based) or revalidateTag on publish, so content updates without a full rebuild. 3) Decide explicitly what happens for params NOT in the list (a post published after the build): should it render on first request and then be cached, or be a hard 404? State the choice instead of accepting the default blindly. 4) Recognize the true exceptions: routes reading cookies, headers, or session data are per-visitor and cannot be pre-built — do not force generateStaticParams onto them. 5) For huge sets, pre-build the subset that matters (recent, popular) and let the long tail render on demand. If you cannot list where the params come from, find that source before writing the route. Only implement once you can state the param source, the fallback policy, and the freshness plan, and explain why each route is static, partially static, or dynamic — not just that the pages load in dev.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #510\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}