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.

File-Based Routing

Flat files in src/app directly create URL routes without needing a folder.

Overview

Bini.js supports file-based routing - a file placed directly in src/app/ becomes a route, without a folder. For example about.tsx creates /about.

File PathURL
src/app/page.tsx/
src/app/about.tsx/about
src/app/contact.tsx/contact
src/app/blog.tsx/blog

Basic File Routing

A file in src/app directly maps to a URL. The file must default-export a React component.

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

Flat Files vs Folders

A flat file and a folder with a page.tsx produce the same URL. Use a flat file for simple pages, and a folder when you need a co-located layout.tsx, loading.tsx, or private folders like _components.

ApproachFile PathURL
File-basedsrc/app/about.tsx/about
Folder-basedsrc/app/about/page.tsx/about
File-basedsrc/app/dashboard.tsx/dashboard
Folder-basedsrc/app/dashboard/page.tsx/dashboard
app
about.tsx
contact
page.tsx
/aboutRoutable
/contactRoutable

Index Files

index.tsx inside a folder maps to that folder's URL. It is the file-based equivalent of page.tsx in the same folder.

app
dashboard
index.tsx
settings
index.tsx
blog
index.tsx
page.tsx
/dashboardRoutable
/dashboard/settingsRoutable
/blogRoutable
/Routable
index.tsx and page.tsx produce the same URL for a folder. Pick one pattern and stay consistent.

File Extensions

Pages and routing files support .tsx, .jsx, .ts, and .js. Pages can also be .mdx or .md. Routing files like layout.tsx, loading.tsx, and error.tsx must use one of the four script extensions.

ExtensionPagesRouting files
.tsxYesYes
.jsxYesYes
.tsYesYes
.jsYesYes
.mdxYesNo
.mdYesNo
Only one file can create a given URL. If about.tsx and about.jsx both exist, the router throws a route conflict. Delete one of them.

Reserved Names

These file names are special files, not routes. They configure a folder or a route but never become a URL on their own.

File NameCreates URL?Reason
page.tsxYes - via folderDefines the page for a folder
layout.tsxNoShared layout for a folder
loading.tsxNoLoading UI
error.tsxNoError UI
not-found.tsxNo404 UI
template.tsxNoTemplate wrapper
default.tsxNoParallel route fallback
global-error.tsxNoGlobal error fallback

Complete Example

A project using file-based routes alongside a folder-based route and a special file.

app
page.tsx
about.tsx
contact.tsx
pricing.tsx
dashboard
index.tsx
settings.tsx
layout.tsx
/Routable
/aboutRoutable
/contactRoutable
/pricingRoutable
/dashboardRoutable
/dashboard/settingsRoutable
-Not Routable
File PathURLCreates URL?
src/app/page.tsx/Yes
src/app/about.tsx/aboutYes - flat file
src/app/contact.tsx/contactYes - flat file
src/app/dashboard/index.tsx/dashboardYes - index file
src/app/dashboard/settings.tsx/dashboard/settingsYes - nested flat file
src/app/layout.tsx-No - reserved name

Folder-Based Routing

Define routes with folders and page files inside them.

Dynamic Routes

Match URL segments with dynamic parameters and catch-alls.

MDX & Markdown Pages

Write routes as .mdx or .md files.

Linking and Navigating

Navigate between routes with Link, useNavigate, and prefetching.

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?
PreviousFolder-Based Routing
NextDynamic Routes

On this page

  • Overview
  • Basic File Routing
  • Flat Files vs Folders
  • Index Files
  • File Extensions
  • Reserved Names
  • Complete Example
Edit this page on GitHub

File-Based Routing

Flat files in src/app directly create URL routes without needing a folder.

Overview

Bini.js supports file-based routing - a file placed directly in src/app/ becomes a route, without a folder. For example about.tsx creates /about.

File PathURL
src/app/page.tsx/
src/app/about.tsx/about
src/app/contact.tsx/contact
src/app/blog.tsx/blog

Basic File Routing

A file in src/app directly maps to a URL. The file must default-export a React component.

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

Flat Files vs Folders

A flat file and a folder with a page.tsx produce the same URL. Use a flat file for simple pages, and a folder when you need a co-located layout.tsx, loading.tsx, or private folders like _components.

ApproachFile PathURL
File-basedsrc/app/about.tsx/about
Folder-basedsrc/app/about/page.tsx/about
File-basedsrc/app/dashboard.tsx/dashboard
Folder-basedsrc/app/dashboard/page.tsx/dashboard
app
about.tsx
contact
page.tsx
/aboutRoutable
/contactRoutable

Index Files

index.tsx inside a folder maps to that folder's URL. It is the file-based equivalent of page.tsx in the same folder.

app
dashboard
index.tsx
settings
index.tsx
blog
index.tsx
page.tsx
/dashboardRoutable
/dashboard/settingsRoutable
/blogRoutable
/Routable
index.tsx and page.tsx produce the same URL for a folder. Pick one pattern and stay consistent.

File Extensions

Pages and routing files support .tsx, .jsx, .ts, and .js. Pages can also be .mdx or .md. Routing files like layout.tsx, loading.tsx, and error.tsx must use one of the four script extensions.

ExtensionPagesRouting files
.tsxYesYes
.jsxYesYes
.tsYesYes
.jsYesYes
.mdxYesNo
.mdYesNo
Only one file can create a given URL. If about.tsx and about.jsx both exist, the router throws a route conflict. Delete one of them.

Reserved Names

These file names are special files, not routes. They configure a folder or a route but never become a URL on their own.

File NameCreates URL?Reason
page.tsxYes - via folderDefines the page for a folder
layout.tsxNoShared layout for a folder
loading.tsxNoLoading UI
error.tsxNoError UI
not-found.tsxNo404 UI
template.tsxNoTemplate wrapper
default.tsxNoParallel route fallback
global-error.tsxNoGlobal error fallback

Complete Example

A project using file-based routes alongside a folder-based route and a special file.

app
page.tsx
about.tsx
contact.tsx
pricing.tsx
dashboard
index.tsx
settings.tsx
layout.tsx
/Routable
/aboutRoutable
/contactRoutable
/pricingRoutable
/dashboardRoutable
/dashboard/settingsRoutable
-Not Routable
File PathURLCreates URL?
src/app/page.tsx/Yes
src/app/about.tsx/aboutYes - flat file
src/app/contact.tsx/contactYes - flat file
src/app/dashboard/index.tsx/dashboardYes - index file
src/app/dashboard/settings.tsx/dashboard/settingsYes - nested flat file
src/app/layout.tsx-No - reserved name

Folder-Based Routing

Define routes with folders and page files inside them.

Dynamic Routes

Match URL segments with dynamic parameters and catch-alls.

MDX & Markdown Pages

Write routes as .mdx or .md files.

Linking and Navigating

Navigate between routes with Link, useNavigate, and prefetching.

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?
PreviousFolder-Based Routing
NextDynamic Routes

On this page

  • Overview
  • Basic File Routing
  • Flat Files vs Folders
  • Index Files
  • File Extensions
  • Reserved Names
  • Complete Example
Edit this page on GitHub