The Course has launched in Early Access! 🎉
The Modern Full Stack Next.js Course has launched in Early Access with over 50% off!
Feedback
Curriculum
Next.js provides powerful routing capabilities, including dynamic routes and catch-all routes. Let's explore when to use each and how they differ.
Dynamic routes are used when you have a single variable segment in your URL. They're perfect for scenarios where you have a known structure but a dynamic value.
app/blog/[slug]/page.tsx;
This route will match URLs like:
/blog/my-first-post
/blog/nextjs-tips
Catch-all routes are more flexible and can handle multiple dynamic segments. They're ideal when you need to capture an unknown number of parameters.
app/blog/[...slug]/page.tsx;
This route will match URLs like:
/blog/tech/nextjs/routing
/blog/lifestyle/travel/europe/france
Try out the different routing scenarios in this interactive demo to see if they should be a dynamic or catch-all route:
In this demo, try entering different URL paths to see how they're handled:
/blog/my-post
(Dynamic Route)/blog/tech/nextjs/routing
(Catch-all Route)