Careeroza
Optional Catch-all
[[...slug]]
Double brackets make the catch-all optional: it also matches the folder itself. Perfect for a shop with filter paths: app/shop/[[...filters]]/page.tsx.
| URL | params |
|---|---|
/shop | { } (filters is undefined) |
/shop/mobiles | { filters: ['mobiles'] } |
/shop/mobiles/samsung/under-20000 | { filters: ['mobiles', 'samsung', 'under-20000'] } |
export default async function ShopPage({
params,
}: {
params: Promise<{ filters?: string[] }>;
}) {
const { filters = [] } = await params;
const [category, brand] = filters;
return (
<h1>
{category ?? 'All products'} {brand ? '— ' + brand : ''}
</h1>
);
}Choosing a Pattern
| Pattern | Matches /shop | Matches /shop/a | Matches /shop/a/b |
|---|---|---|---|
[slug] | No | Yes | No |
[...slug] | No | Yes | Yes |
[[...slug]] | Yes | Yes | Yes |