Question presented to candidate: "You have app/products/[id]/page.tsx and 50,000 products. What does generateStaticParams do, what happens to an id you did not list, and how would you split the work between build time and runtime?"
What a strong answer should cover:
generateStaticParamsreturns the list of params to prerender at build time for a dynamic segment; the build shows them with the β symbol.- It replaces
getStaticPathsfrom the Pages Router. - By default (
dynamicParams = true) other values are rendered on first request and then cached. - With
dynamicParams = false, values not in the list return 404. - Returning a subset (or an empty array) trades build time for a first-visit render; fetches inside it are memoized with the page.
Clarifying questions expected:
- "Which pages get most of the traffic?" β those are worth prerendering.
- "Can valid ids appear after the build?" β then
dynamicParamsmust stay true.
Code / implementation expected: Yes β a subset list plus the dynamicParams switch.