How do dynamic routes and generateStaticParams work?
Assesses fundamental understanding of Next.js conventions, runtime behavior, and memory/performance considerations.
Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.
Dynamic segments use bracket folders: app/blog/[slug]/page.tsx receives params as a prop, which is a Promise in recent versions. Catch-all routes use [...slug] and optional catch-all uses [[...slug]].
generateStaticParams runs at build time and returns an array of param objects so those pages are pre-rendered:
export async function generateStaticParams() {
const posts = await getPosts();
return posts.map(p => ({ slug: p.slug }));
}
export const dynamicParams = true;
With dynamicParams true, pages not returned at build time are generated on first request and cached; setting it false returns 404 for unknown params. Combined with ISR, the generated pages can revalidate over time. generateMetadata({ params }) gives per-page SEO using the same params.
The older Pages Router equivalent was getStaticPaths with getStaticProps. The App Router model is more flexible because params flow naturally into server components and streaming.
Candidate Response Strategy & Interview Tips
- Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
- Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
- Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
- Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.