DocsPluginsShowcaseReleases
npmStar us on GitHub

Getting Started

IntroductionInstallationProject StructureLayouts and PagesLinking and Navigating

Routing

Folder-Based RoutingFile-Based RoutingDynamic RoutesParallel RoutesIntercepting RoutesCatch-All RoutesMDX & Markdown Pages

Special Files

Loading UIError BoundariesTemplateDefaultNot Found

Data Fetching

LoadersActionsAccessing Route Data

Metadata

Metadata & SEOOpen Graph & TwitterIcons & Favicons

API Routes

API Routes OverviewPlain Function HandlersHono IntegrationDynamic API Routes

Environment Variables

OverviewPrefixes & Client ExposureUsing in API Routes

Styling

CSS OverviewTailwind CSSCSS Modules

Platforms

WebWindowsmacOSLinuxAndroidiOS

Deployment

Deployment OverviewProduction ServerStatic ExportHosting Providers

A native React framework for building cross-platform applications from a single codebase.

Resources

  • Documentation
  • Plugins
  • Showcase
  • Releases

Community

  • GitHub Discussions
  • Reddit
  • Discord
  • LinkedIn

More

  • npm
  • GitHub
  • Issues
  • License

© 2026 Bini Cooperation.

Catch-All Routes

Match multiple URL segments with [...name] and optional [[...name]].

Overview

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.

app
docs
[...slug]
page.tsx
/docs/*
PatternExample URLMatches
[...slug]/docs/api/referenceOne or more segments
[[...slug]]/docs and /docs/apiZero or more segments
For page routes, catch-all values are exposed under params['*'], not the name written in the folder. This is a React Router convention that Bini.js follows.

Basic Usage

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.

app
blog
[...slug]
page.tsx
products
[...path]
page.tsx
/blog/*
/products/*

/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['*'].

Accessing Parameters

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 /.

src/app/docs/[...slug]/page.tsx
export default function DocsPage() {
  const params = useParams()
  // For a page route, the catch-all is under params['*']
  const path = params['*'] ?? ''

  return (
    <div>
      <h1>Documentation</h1>
      <p>Path: {path}</p>
    </div>
  )
}
URLparams['*']
/docs/getting-started'getting-started'
/docs/api/reference'api/reference'
/docs/guides/routing/basics'guides/routing/basics'
The catch-all is a string under '*', not an array. Split on / if you need individual segments: params['*']?.split('/').

Nested Catch-All Routes

Combine a catch-all with static and dynamic segments. Each combination creates its own URL.

app
products
[category]
[...slug]
page.tsx
blog
featured
page.tsx
[...slug]
page.tsx
/products/:cat/*
/blog/featured
/blog/*
src/app/products/[category]/[...slug]/page.tsx
export default function ProductPage() {
  const { category } = useParams<{ category: string }>()
  const path = useParams()['*'] ?? ''

  return (
    <div>
      <h1>Category: {category}</h1>
      <p>Path: {path}</p>
    </div>
  )
}

Optional Catch-All Routes

[[...name]] makes the catch-all optional. It matches the parent path (zero segments) and any nested path (one or more segments).

app
shop
[[...slug]]
page.tsx
/shop, /shop/*
src/app/shop/[[...slug]]/page.tsx
export default function ShopPage() {
  const path = useParams()['*'] ?? ''

  if (!path) {
    return <h1>Shop Home</h1>
  }

  return (
    <div>
      <h1>Category: {path}</h1>
    </div>
  )
}
URLparams['*']Note
/shop'' (empty)Parent path also matches
/shop/clothing'clothing'
/shop/clothing/shirts'clothing/shirts'

File-Based Catch-All Routes

A catch-all can be a flat file instead of a folder. It creates the same URL with less nesting.

app
docs
[...slug].tsx
blog
[...slug].tsx
/docs/*
/blog/*
src/app/blog/[...slug].tsx
export default function BlogArchive() {
  const path = useParams()['*'] ?? ''
  return <h1>Archive: {path}</h1>
}

Route Priority

When multiple routes could match a URL, the more specific one wins: static routes first, then dynamic, then catch-alls.

app
blog
featured
page.tsx
[slug]
page.tsx
[...slug]
page.tsx
/blog/featured
/blog/:slug
/blog/*
URLMatched route
/blog/featuredStatic - featured/page.tsx
/blog/hello-worldDynamic - [slug]/page.tsx
/blog/2024/01/hello-worldCatch-all - [...slug]/page.tsx

Use Cases

Catch-all routes fit any multi-segment structure where the number of segments varies.

Use caseExample URLRoute
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/123v1/[...path]

Complete Example

A project combining static, dynamic, and catch-all routes at every level.

app
blog
featured
page.tsx
[slug]
page.tsx
[...slug]
page.tsx
docs
[[...slug]]
page.tsx
products
[category]
[...slug]
page.tsx
/blog/featured
/blog/:slug
/blog/*
/docs, /docs/*
/products/:cat/*
URLMatched route
/blog/featuredStatic
/blog/hello-worldDynamic [slug]
/blog/2024/01/hello-worldCatch-all [...slug]
/docsOptional catch-all [[...slug]] (empty)
/docs/guides/routingOptional catch-all [[...slug]]
/products/electronics/phones/iphoneNested dynamic + catch-all

Dynamic Routes

Match URL segments with dynamic parameters and catch-alls.

Intercepting Routes

Render alternative content when navigating from within the app.

Parallel Routes

Render multiple routes in the same layout with named slots.

Folder-Based Routing

Define routes with folders and page files inside them.

MDX & Markdown Pages

Write routes as .mdx or .md files.

Static Export

How every route is pre-rendered to HTML at build time.

Was this helpful?
PreviousIntercepting Routes
NextMDX & Markdown

On this page

  • Overview
  • Basic Usage
  • Accessing Parameters
  • Nested Catch-All Routes
  • Optional Catch-All Routes
  • File-Based Catch-All Routes
  • Route Priority
  • Use Cases
  • Complete Example
Edit this page on GitHub

Catch-All Routes

Match multiple URL segments with [...name] and optional [[...name]].

Overview

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.

app
docs
[...slug]
page.tsx
/docs/*
PatternExample URLMatches
[...slug]/docs/api/referenceOne or more segments
[[...slug]]/docs and /docs/apiZero or more segments
For page routes, catch-all values are exposed under params['*'], not the name written in the folder. This is a React Router convention that Bini.js follows.

Basic Usage

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.

app
blog
[...slug]
page.tsx
products
[...path]
page.tsx
/blog/*
/products/*

/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['*'].

Accessing Parameters

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 /.

src/app/docs/[...slug]/page.tsx
export default function DocsPage() {
  const params = useParams()
  // For a page route, the catch-all is under params['*']
  const path = params['*'] ?? ''

  return (
    <div>
      <h1>Documentation</h1>
      <p>Path: {path}</p>
    </div>
  )
}
URLparams['*']
/docs/getting-started'getting-started'
/docs/api/reference'api/reference'
/docs/guides/routing/basics'guides/routing/basics'
The catch-all is a string under '*', not an array. Split on / if you need individual segments: params['*']?.split('/').

Nested Catch-All Routes

Combine a catch-all with static and dynamic segments. Each combination creates its own URL.

app
products
[category]
[...slug]
page.tsx
blog
featured
page.tsx
[...slug]
page.tsx
/products/:cat/*
/blog/featured
/blog/*
src/app/products/[category]/[...slug]/page.tsx
export default function ProductPage() {
  const { category } = useParams<{ category: string }>()
  const path = useParams()['*'] ?? ''

  return (
    <div>
      <h1>Category: {category}</h1>
      <p>Path: {path}</p>
    </div>
  )
}

Optional Catch-All Routes

[[...name]] makes the catch-all optional. It matches the parent path (zero segments) and any nested path (one or more segments).

app
shop
[[...slug]]
page.tsx
/shop, /shop/*
src/app/shop/[[...slug]]/page.tsx
export default function ShopPage() {
  const path = useParams()['*'] ?? ''

  if (!path) {
    return <h1>Shop Home</h1>
  }

  return (
    <div>
      <h1>Category: {path}</h1>
    </div>
  )
}
URLparams['*']Note
/shop'' (empty)Parent path also matches
/shop/clothing'clothing'
/shop/clothing/shirts'clothing/shirts'

File-Based Catch-All Routes

A catch-all can be a flat file instead of a folder. It creates the same URL with less nesting.

app
docs
[...slug].tsx
blog
[...slug].tsx
/docs/*
/blog/*
src/app/blog/[...slug].tsx
export default function BlogArchive() {
  const path = useParams()['*'] ?? ''
  return <h1>Archive: {path}</h1>
}

Route Priority

When multiple routes could match a URL, the more specific one wins: static routes first, then dynamic, then catch-alls.

app
blog
featured
page.tsx
[slug]
page.tsx
[...slug]
page.tsx
/blog/featured
/blog/:slug
/blog/*
URLMatched route
/blog/featuredStatic - featured/page.tsx
/blog/hello-worldDynamic - [slug]/page.tsx
/blog/2024/01/hello-worldCatch-all - [...slug]/page.tsx

Use Cases

Catch-all routes fit any multi-segment structure where the number of segments varies.

Use caseExample URLRoute
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/123v1/[...path]

Complete Example

A project combining static, dynamic, and catch-all routes at every level.

app
blog
featured
page.tsx
[slug]
page.tsx
[...slug]
page.tsx
docs
[[...slug]]
page.tsx
products
[category]
[...slug]
page.tsx
/blog/featured
/blog/:slug
/blog/*
/docs, /docs/*
/products/:cat/*
URLMatched route
/blog/featuredStatic
/blog/hello-worldDynamic [slug]
/blog/2024/01/hello-worldCatch-all [...slug]
/docsOptional catch-all [[...slug]] (empty)
/docs/guides/routingOptional catch-all [[...slug]]
/products/electronics/phones/iphoneNested dynamic + catch-all

Dynamic Routes

Match URL segments with dynamic parameters and catch-alls.

Intercepting Routes

Render alternative content when navigating from within the app.

Parallel Routes

Render multiple routes in the same layout with named slots.

Folder-Based Routing

Define routes with folders and page files inside them.

MDX & Markdown Pages

Write routes as .mdx or .md files.

Static Export

How every route is pre-rendered to HTML at build time.

Was this helpful?
PreviousIntercepting Routes
NextMDX & Markdown

On this page

  • Overview
  • Basic Usage
  • Accessing Parameters
  • Nested Catch-All Routes
  • Optional Catch-All Routes
  • File-Based Catch-All Routes
  • Route Priority
  • Use Cases
  • Complete Example
Edit this page on GitHub