Question presented to candidate: "How does Next.js decide whether a route is static or dynamic, how can you tell which one you got, and what does each choice cost?"
What a strong answer should cover:
- Static rendering happens at build time (or at revalidation); the result is served as a file to every user.
- Dynamic rendering happens on each request; it is needed for per-request data.
- Using a Request-time API such as
cookies(),headers(),searchParamsorconnection(), or uncached data, makes a route dynamic. - The build output shows the result per route: β static, β SSG with generateStaticParams, Ζ dynamic, and β partial prerender with Cache Components.
- The cost of dynamic is time to first byte, which streaming with loading.js or PPR reduces.
Clarifying questions expected:
- "Does the content depend on who is asking?" β if not, it should be static.
- "How fresh must it be?" β minutes of staleness allow static with revalidation (ISR).
Code / implementation expected: Yes β one static page, one ISR page and one dynamic page.