Routing Questions
How do dynamic routes work, and what changed for params in Next.js 15?
A folder in brackets is a dynamic segment: app/products/[id]/page.tsx matches /products/42. Since Next.js 15 params and searchParams are Promises (sync access removed in 16):
export default async function Page({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params;
return <h1>Product {id}</h1>;
}Explain [slug], [...slug] and [[...slug]].
| Pattern | /shop | /shop/a | /shop/a/b | params |
|---|---|---|---|---|
[slug] | No | Yes | No | { slug: 'a' } |
[...slug] | No | Yes | Yes | { slug: ['a','b'] } |
[[...slug]] | Yes | Yes | Yes | { slug?: string[] } |
What are route groups and private folders?
(name) folders group routes without adding a URL segment, so (shop) and (auth) can have different layouts at the same URL level, or several root layouts. _name folders are private: never routable, good for colocated components.
What are parallel and intercepting routes?
Parallel routes (@slot folders) render several pages in one layout at once, each with its own loading/error state (dashboards). Intercepting routes ((.), (..), (...)) show a route inside the current layout during client navigation, usually as a modal, while a direct visit or reload shows the full page. Together they build "photo modal with shareable URL" patterns.