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.

Folder-Based Routing

Folders inside src/app define URL segments. Each folder becomes a part of the URL path.

Overview

Bini.js uses folder-based routing - every folder inside src/app/ becomes a URL segment. Add page.tsx inside that folder to make the route accessible.

Folder PatternURLType
src/app/about/page.tsx/aboutStatic folder - creates URL
src/app/dashboard/settings/page.tsx/dashboard/settingsNested folder - creates URL
src/app/(marketing)/about/page.tsx/aboutRoute group - folder ignored
src/app/_components/Header.tsx-Private folder - no URL
src/app/.internal/page.tsx-Private folder - no URL

Basic Folder Routing

Every folder becomes a URL segment. Add a page.tsx file to expose it.

app
page.tsx
about
page.tsx
blog
page.tsx
dashboard
page.tsx
/Routable
/aboutRoutable
/blogRoutable
/dashboardRoutable
src/app/about/page.tsx
export default function AboutPage() {
  return <h1>About</h1>
}

Nested Routes

Nest folders to create nested URL segments. Each nested folder adds one segment.

app
blog
page.tsx
authors
page.tsx
dashboard
page.tsx
settings
page.tsx
/blogRoutable
/blog/authorsRoutable
/dashboardRoutable
/dashboard/settingsRoutable
src/app/blog/authors/page.tsx
export default function AuthorsPage() {
  return (
    <ul>
      <li>Alice</li>
      <li>Bob</li>
    </ul>
  )
}
Layouts from parent folders wrap child routes. A layout.tsx at the root wraps every page.

Route Groups

Wrap a folder name in parentheses, like (marketing), to organize routes without adding a URL segment. The group name is dropped from the path.

app
(marketing)
about
page.tsx
(shop)
cart
page.tsx
/aboutRoutable
/cartRoutable

Both pages are routed normally: /about and /cart. The group folders themselves never appear in the URL.

src/app/(marketing)/about/page.tsx
export default function AboutPage() {
  return <h1>About</h1>
}

Each group can also have its own layout.tsx that wraps only the routes inside that group.

src/app/(marketing)/layout.tsx
import { Outlet } from 'react-router-dom'

export default function MarketingLayout() {
  return (
    <div>
      <nav>Marketing Nav</nav>
      <main><Outlet /></main>
    </div>
  )
}

Private Folders

Prefix a folder with _ or . to keep it out of routing. Private folders do not create URLs. Use them to keep components, helpers, and data next to the route that uses them.

app
_components
Header.tsx
_lib
utils.ts
blog
page.tsx
_components
PostCard.tsx
/_components/HeaderNot Routable
/_lib/utilsNot Routable
/blogRoutable
/blog/_components/PostCardNot Routable
Folder PatternCreates URL?Description
_componentsNoPrivate folder (underscore prefix)
.hiddenNoPrivate folder (dot prefix)
blog/_componentsNoPrivate folder inside a route
about, blogYesPublic folder with page.tsx

Nearest Wins with Folders

loading.tsx, not-found.tsx, and error.tsx use nearest-wins resolution. A file in a subfolder only affects that subfolder, and shadows the same file from a parent folder.

app
layout.tsx
page.tsx
loading.tsx
not-found.tsx
error.tsx
dashboard
layout.tsx
page.tsx
loading.tsx
error.tsx
settings
page.tsx

Resolution order: route's own folder → parent folders → built-in default.

src/app/dashboard/loading.tsx
export default function DashboardLoading() {
  return <p>Loading dashboard…</p>
}

Folder Types and URLs

Each folder type affects URLs differently. Static and nested folders create URL segments. Route groups and private folders do not.

Folder TypeExampleCreates URL?
Staticsrc/app/about/page.tsxYes - /about
Nestedsrc/app/blog/authors/page.tsxYes - /blog/authors
Route groupsrc/app/(marketing)/about/page.tsxYes - /about (group dropped)
Privatesrc/app/_components/Header.tsxNo

Complete Example

A folder-based project showing which folders create URLs and which do not.

app
(marketing)
page.tsx
about
page.tsx
_components
Button.tsx
blog
layout.tsx
page.tsx
authors
page.tsx
layout.tsx
page.tsx
loading.tsx
error.tsx
not-found.tsx
/Routable
/aboutRoutable
/_components/ButtonNot Routable
/blogRoutable
/blog/authorsRoutable
/Routable
Folder PathURLCreates URL?
src/app/page.tsx/Yes
src/app/about/page.tsx/aboutYes - static folder
src/app/blog/page.tsx/blogYes - static folder
src/app/blog/authors/page.tsx/blog/authorsYes - nested folder
src/app/(marketing)/about/page.tsx/aboutYes, group folder ignored
src/app/_components/Button.tsx-No - private folder
src/app/blog/_components/PostCard.tsx-No - private folder

File-Based Routing

Define routes with flat files instead of folders.

Dynamic Routes

Match URL segments with dynamic parameters and catch-alls.

Parallel Routes

Render multiple routes in the same layout with named slots.

Catch-All Routes

Match any number of trailing URL segments.

Layouts and Pages

Create your first pages and wrap them in shared layouts.

Project Structure

Learn how a Bini.js project is organized and what each folder contains.

Was this helpful?
PreviousLinking and Navigating
NextFile-Based Routing

On this page

  • Overview
  • Basic Folder Routing
  • Nested Routes
  • Route Groups
  • Private Folders
  • Nearest Wins with Folders
  • Folder Types and URLs
  • Complete Example
Edit this page on GitHub

Folder-Based Routing

Folders inside src/app define URL segments. Each folder becomes a part of the URL path.

Overview

Bini.js uses folder-based routing - every folder inside src/app/ becomes a URL segment. Add page.tsx inside that folder to make the route accessible.

Folder PatternURLType
src/app/about/page.tsx/aboutStatic folder - creates URL
src/app/dashboard/settings/page.tsx/dashboard/settingsNested folder - creates URL
src/app/(marketing)/about/page.tsx/aboutRoute group - folder ignored
src/app/_components/Header.tsx-Private folder - no URL
src/app/.internal/page.tsx-Private folder - no URL

Basic Folder Routing

Every folder becomes a URL segment. Add a page.tsx file to expose it.

app
page.tsx
about
page.tsx
blog
page.tsx
dashboard
page.tsx
/Routable
/aboutRoutable
/blogRoutable
/dashboardRoutable
src/app/about/page.tsx
export default function AboutPage() {
  return <h1>About</h1>
}

Nested Routes

Nest folders to create nested URL segments. Each nested folder adds one segment.

app
blog
page.tsx
authors
page.tsx
dashboard
page.tsx
settings
page.tsx
/blogRoutable
/blog/authorsRoutable
/dashboardRoutable
/dashboard/settingsRoutable
src/app/blog/authors/page.tsx
export default function AuthorsPage() {
  return (
    <ul>
      <li>Alice</li>
      <li>Bob</li>
    </ul>
  )
}
Layouts from parent folders wrap child routes. A layout.tsx at the root wraps every page.

Route Groups

Wrap a folder name in parentheses, like (marketing), to organize routes without adding a URL segment. The group name is dropped from the path.

app
(marketing)
about
page.tsx
(shop)
cart
page.tsx
/aboutRoutable
/cartRoutable

Both pages are routed normally: /about and /cart. The group folders themselves never appear in the URL.

src/app/(marketing)/about/page.tsx
export default function AboutPage() {
  return <h1>About</h1>
}

Each group can also have its own layout.tsx that wraps only the routes inside that group.

src/app/(marketing)/layout.tsx
import { Outlet } from 'react-router-dom'

export default function MarketingLayout() {
  return (
    <div>
      <nav>Marketing Nav</nav>
      <main><Outlet /></main>
    </div>
  )
}

Private Folders

Prefix a folder with _ or . to keep it out of routing. Private folders do not create URLs. Use them to keep components, helpers, and data next to the route that uses them.

app
_components
Header.tsx
_lib
utils.ts
blog
page.tsx
_components
PostCard.tsx
/_components/HeaderNot Routable
/_lib/utilsNot Routable
/blogRoutable
/blog/_components/PostCardNot Routable
Folder PatternCreates URL?Description
_componentsNoPrivate folder (underscore prefix)
.hiddenNoPrivate folder (dot prefix)
blog/_componentsNoPrivate folder inside a route
about, blogYesPublic folder with page.tsx

Nearest Wins with Folders

loading.tsx, not-found.tsx, and error.tsx use nearest-wins resolution. A file in a subfolder only affects that subfolder, and shadows the same file from a parent folder.

app
layout.tsx
page.tsx
loading.tsx
not-found.tsx
error.tsx
dashboard
layout.tsx
page.tsx
loading.tsx
error.tsx
settings
page.tsx

Resolution order: route's own folder → parent folders → built-in default.

src/app/dashboard/loading.tsx
export default function DashboardLoading() {
  return <p>Loading dashboard…</p>
}

Folder Types and URLs

Each folder type affects URLs differently. Static and nested folders create URL segments. Route groups and private folders do not.

Folder TypeExampleCreates URL?
Staticsrc/app/about/page.tsxYes - /about
Nestedsrc/app/blog/authors/page.tsxYes - /blog/authors
Route groupsrc/app/(marketing)/about/page.tsxYes - /about (group dropped)
Privatesrc/app/_components/Header.tsxNo

Complete Example

A folder-based project showing which folders create URLs and which do not.

app
(marketing)
page.tsx
about
page.tsx
_components
Button.tsx
blog
layout.tsx
page.tsx
authors
page.tsx
layout.tsx
page.tsx
loading.tsx
error.tsx
not-found.tsx
/Routable
/aboutRoutable
/_components/ButtonNot Routable
/blogRoutable
/blog/authorsRoutable
/Routable
Folder PathURLCreates URL?
src/app/page.tsx/Yes
src/app/about/page.tsx/aboutYes - static folder
src/app/blog/page.tsx/blogYes - static folder
src/app/blog/authors/page.tsx/blog/authorsYes - nested folder
src/app/(marketing)/about/page.tsx/aboutYes, group folder ignored
src/app/_components/Button.tsx-No - private folder
src/app/blog/_components/PostCard.tsx-No - private folder

File-Based Routing

Define routes with flat files instead of folders.

Dynamic Routes

Match URL segments with dynamic parameters and catch-alls.

Parallel Routes

Render multiple routes in the same layout with named slots.

Catch-All Routes

Match any number of trailing URL segments.

Layouts and Pages

Create your first pages and wrap them in shared layouts.

Project Structure

Learn how a Bini.js project is organized and what each folder contains.

Was this helpful?
PreviousLinking and Navigating
NextFile-Based Routing

On this page

  • Overview
  • Basic Folder Routing
  • Nested Routes
  • Route Groups
  • Private Folders
  • Nearest Wins with Folders
  • Folder Types and URLs
  • Complete Example
Edit this page on GitHub