Dynamic Routes ([slug])
Capturing URL parameters to build dynamic pages.
Bracket notation
When you are building an e-commerce site, you can't manually create a folder for every single product (e.g., /product/1, /product/2, etc.).
Instead, Next.js uses Dynamic Routes. By wrapping a folder name in square brackets—such as [id] or [slug]—you tell the router to capture that segment of the URL as a dynamic parameter.
The params prop
When a user visits /blog/my-first-post, and your folder structure is app/blog/[slug]/page.tsx, Next.js routes the request to that page.
Crucially, it extracts the value 'my-first-post' and passes it directly into your page.tsx component via a prop called params.
The Next 15 Promise Rule
Here is the most critical thing to know for modern Next.js (v15+): **the params prop is a Promise**.
Because extracting parameters from the request happens asynchronously during the server rendering lifecycle, you must await the params object before you can read from it: const { slug } = await params;.
Parameter Extraction
Type a custom user ID into the URL bar and hit enter. Watch how the Next.js router extracts the segment, resolves the Promise, and injects it into the Page component.
Check yourself
Pick an answer to lock it in, then read why. Getting one wrong is part of how it sticks.
Remember this
- Wrap a folder name in brackets
[id]to create a dynamic route. - The extracted value is passed to the component via the
paramsprop. - In Next.js 15+,
paramsis a **Promise**. You mustawaitit. - You can nest multiple dynamic segments in a single route.
Done with this concept?
Mark it complete to track your progress. No login needed.