03 / 10

What are dynamic routes?

Difficulty: 5/10
file-system routing, fallback strategies, incremental static regeneration

When you don't know the exact segment names ahead of time and want to create routes from dynamic data, you can use Dynamic Segments that are filled in at request time or prerendered at build time.

Scenario Questions

0-2 years experience

  1. 1We need a product page at /products/[id]. How would you set up the file structure in a Next.js app to handle URLs like /products/123?
  2. 2If you navigate to /blog/awesome-post and the corresponding dynamic route file is missing, what does Next.js render?
  3. 3How does Next.js expose the value of the `id` param inside getStaticProps for a dynamic route?

2-5 years experience

  1. 1Our blog uses a catch‑all route [...slug]. After adding a new article, the page shows a 404 until we rebuild. What could be causing that and how would you fix it?
  2. 2We want to pre‑render some product pages at build time but fallback to server‑side rendering for the rest. Which dynamic route options would you choose and why?
  3. 3During a deployment we noticed that navigating from /users/1 to /users/2 triggers a full page reload. What might be wrong with our dynamic route implementation?

5-8 years experience

  1. 1We have a high‑traffic marketplace with dynamic product pages. Discuss the trade‑offs between using getStaticProps with fallback: 'blocking' versus getServerSideProps for those routes.
  2. 2Our SEO team wants each dynamic route to have its own meta tags generated at request time, but we also need to keep build times low. How would you architect the data fetching and caching strategy?
  3. 3Explain how you would handle incremental static regeneration for a dynamic route that receives frequent updates, ensuring stale data is minimized without overloading the origin.

8+ years experience

  1. 1Our monorepo contains multiple Next.js apps, some of which share a common set of dynamic routes. How would you design a shared routing library or pattern that scales across teams while preserving type safety and route‑level access control?
  2. 2We need to migrate a legacy server‑rendered site to Next.js, preserving existing URL structures that include deep dynamic segments. What architectural steps and migration plan would you propose to avoid breaking existing inbound links?
  3. 3Considering long‑term maintainability, how would you enforce conventions around dynamic route naming, fallback strategies, and ISR across dozens of micro‑frontends in a large organization?

Follow-up Questions

  • Can you sketch the folder and code structure you’d use?
  • What edge cases or error handling would you add?
  • How would you verify that the routing behaves correctly in production?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.