Catch-all Routes with [...param] in Next.js
📖 Scenario: You are building a simple Next.js website that shows different pages based on the URL path. You want to catch all paths under a certain folder and display them dynamically.
🎯 Goal: Create a catch-all route using [...param] in Next.js that captures all URL segments after a base path and displays them as a list on the page.
📋 What You'll Learn
Create a Next.js page file with a catch-all route named
[...param] inside the app/docs/ folderExtract the catch-all route parameter named
param using Next.js server component propsRender the
param segments as an unordered list (<ul>) on the pageHandle the case when no segments are provided by showing a message
No path segments provided💡 Why This Matters
🌍 Real World
Catch-all routes are useful for building documentation sites, blogs, or any app where the URL path can have many nested levels and you want to handle them dynamically.
💼 Career
Understanding catch-all routes in Next.js is important for frontend developers working on dynamic websites and apps that require flexible routing and content rendering.
Progress0 / 4 steps