CodeZettaInterview Hub

Next.js · SSG · Junior · Live Coding

How do you statically generate dynamic routes?

Short Interview Answer

Provide a set of paths at build (generateStaticParams) and render those pages ahead of time.

Detailed Explanation

In App Router, `generateStaticParams` replaces getStaticPaths. Decide fallback behavior for unknown paths (404 vs on-demand generation).

Example

export async function generateStaticParams() {
  return [{ slug: 'a' }, { slug: 'b' }];
}

Did you know this answer?