Match multiple URL segments with [...name] and optional [[...name]].
A catch-all route matches multiple URL segments in one route using [...name]. The optional version [[...name]] also matches the parent path. Both create a URL for any depth.
| Pattern | Example URL | Matches |
|---|---|---|
| [...slug] | /docs/api/reference | One or more segments |
| [[...slug]] | /docs and /docs/api | Zero or more segments |
params['*'], not the name written in the folder. This is a React Router convention that Bini.js follows.Create a catch-all by naming a folder or file [...name]. It matches any depth after the parent path, but requires at least one segment.
/blog/getting-started matches [...slug] with one segment, and /blog/guides/routing/basics matches with three. The param name (slug, path) is what you read from params['*'].
Read the catch-all with useParams(). For page routes, the value is under the '*' key. It is a string of the matched segments, joined by /.
| URL | params['*'] |
|---|---|
| /docs/getting-started | 'getting-started' |
| /docs/api/reference | 'api/reference' |
| /docs/guides/routing/basics | 'guides/routing/basics' |
'*', not an array. Split on / if you need individual segments: params['*']?.split('/').Combine a catch-all with static and dynamic segments. Each combination creates its own URL.
[[...name]] makes the catch-all optional. It matches the parent path (zero segments) and any nested path (one or more segments).
| URL | params['*'] | Note |
|---|---|---|
| /shop | '' (empty) | Parent path also matches |
| /shop/clothing | 'clothing' | |
| /shop/clothing/shirts | 'clothing/shirts' |
A catch-all can be a flat file instead of a folder. It creates the same URL with less nesting.
When multiple routes could match a URL, the more specific one wins: static routes first, then dynamic, then catch-alls.
| URL | Matched route |
|---|---|
| /blog/featured | Static - featured/page.tsx |
| /blog/hello-world | Dynamic - [slug]/page.tsx |
| /blog/2024/01/hello-world | Catch-all - [...slug]/page.tsx |
Catch-all routes fit any multi-segment structure where the number of segments varies.
| Use case | Example URL | Route |
|---|---|---|
| Documentation | /docs/guides/routing/basics | [...slug] |
| E-commerce categories | /products/electronics/phones/iphone | [category]/[...slug] |
| Blog archives | /blog/2024/01/hello-world | [...slug] |
| Multi-language sites | /en/docs/getting-started | [locale]/[...slug] |
| File browser | /files/docs/guides | [...path] |
| API versioning | /api/v1/users/123 | v1/[...path] |
A project combining static, dynamic, and catch-all routes at every level.
| URL | Matched route |
|---|---|
| /blog/featured | Static |
| /blog/hello-world | Dynamic [slug] |
| /blog/2024/01/hello-world | Catch-all [...slug] |
| /docs | Optional catch-all [[...slug]] (empty) |
| /docs/guides/routing | Optional catch-all [[...slug]] |
| /products/electronics/phones/iphone | Nested dynamic + catch-all |
Match URL segments with dynamic parameters and catch-alls.
Render alternative content when navigating from within the app.
Render multiple routes in the same layout with named slots.
Define routes with folders and page files inside them.
Write routes as .mdx or .md files.
How every route is pre-rendered to HTML at build time.
Match multiple URL segments with [...name] and optional [[...name]].
A catch-all route matches multiple URL segments in one route using [...name]. The optional version [[...name]] also matches the parent path. Both create a URL for any depth.
| Pattern | Example URL | Matches |
|---|---|---|
| [...slug] | /docs/api/reference | One or more segments |
| [[...slug]] | /docs and /docs/api | Zero or more segments |
params['*'], not the name written in the folder. This is a React Router convention that Bini.js follows.Create a catch-all by naming a folder or file [...name]. It matches any depth after the parent path, but requires at least one segment.
/blog/getting-started matches [...slug] with one segment, and /blog/guides/routing/basics matches with three. The param name (slug, path) is what you read from params['*'].
Read the catch-all with useParams(). For page routes, the value is under the '*' key. It is a string of the matched segments, joined by /.
| URL | params['*'] |
|---|---|
| /docs/getting-started | 'getting-started' |
| /docs/api/reference | 'api/reference' |
| /docs/guides/routing/basics | 'guides/routing/basics' |
'*', not an array. Split on / if you need individual segments: params['*']?.split('/').Combine a catch-all with static and dynamic segments. Each combination creates its own URL.
[[...name]] makes the catch-all optional. It matches the parent path (zero segments) and any nested path (one or more segments).
| URL | params['*'] | Note |
|---|---|---|
| /shop | '' (empty) | Parent path also matches |
| /shop/clothing | 'clothing' | |
| /shop/clothing/shirts | 'clothing/shirts' |
A catch-all can be a flat file instead of a folder. It creates the same URL with less nesting.
When multiple routes could match a URL, the more specific one wins: static routes first, then dynamic, then catch-alls.
| URL | Matched route |
|---|---|
| /blog/featured | Static - featured/page.tsx |
| /blog/hello-world | Dynamic - [slug]/page.tsx |
| /blog/2024/01/hello-world | Catch-all - [...slug]/page.tsx |
Catch-all routes fit any multi-segment structure where the number of segments varies.
| Use case | Example URL | Route |
|---|---|---|
| Documentation | /docs/guides/routing/basics | [...slug] |
| E-commerce categories | /products/electronics/phones/iphone | [category]/[...slug] |
| Blog archives | /blog/2024/01/hello-world | [...slug] |
| Multi-language sites | /en/docs/getting-started | [locale]/[...slug] |
| File browser | /files/docs/guides | [...path] |
| API versioning | /api/v1/users/123 | v1/[...path] |
A project combining static, dynamic, and catch-all routes at every level.
| URL | Matched route |
|---|---|
| /blog/featured | Static |
| /blog/hello-world | Dynamic [slug] |
| /blog/2024/01/hello-world | Catch-all [...slug] |
| /docs | Optional catch-all [[...slug]] (empty) |
| /docs/guides/routing | Optional catch-all [[...slug]] |
| /products/electronics/phones/iphone | Nested dynamic + catch-all |
Match URL segments with dynamic parameters and catch-alls.
Render alternative content when navigating from within the app.
Render multiple routes in the same layout with named slots.
Define routes with folders and page files inside them.
Write routes as .mdx or .md files.
How every route is pre-rendered to HTML at build time.