Flat files in src/app directly create URL routes without needing a folder.
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 Path | URL |
|---|---|
| src/app/page.tsx | / |
| src/app/about.tsx | /about |
| src/app/contact.tsx | /contact |
| src/app/blog.tsx | /blog |
A file in src/app directly maps to a URL. The file must default-export a React component.
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.
| Approach | File Path | URL |
|---|---|---|
| File-based | src/app/about.tsx | /about |
| Folder-based | src/app/about/page.tsx | /about |
| File-based | src/app/dashboard.tsx | /dashboard |
| Folder-based | src/app/dashboard/page.tsx | /dashboard |
index.tsx inside a folder maps to that folder's URL. It is the file-based equivalent of page.tsx in the same folder.
index.tsx and page.tsx produce the same URL for a folder. Pick one pattern and stay consistent.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.
| Extension | Pages | Routing files |
|---|---|---|
| .tsx | Yes | Yes |
| .jsx | Yes | Yes |
| .ts | Yes | Yes |
| .js | Yes | Yes |
| .mdx | Yes | No |
| .md | Yes | No |
about.tsx and about.jsx both exist, the router throws a route conflict. Delete one of them.These file names are special files, not routes. They configure a folder or a route but never become a URL on their own.
| File Name | Creates URL? | Reason |
|---|---|---|
| page.tsx | Yes - via folder | Defines the page for a folder |
| layout.tsx | No | Shared layout for a folder |
| loading.tsx | No | Loading UI |
| error.tsx | No | Error UI |
| not-found.tsx | No | 404 UI |
| template.tsx | No | Template wrapper |
| default.tsx | No | Parallel route fallback |
| global-error.tsx | No | Global error fallback |
A project using file-based routes alongside a folder-based route and a special file.
| File Path | URL | Creates URL? |
|---|---|---|
| src/app/page.tsx | / | Yes |
| src/app/about.tsx | /about | Yes - flat file |
| src/app/contact.tsx | /contact | Yes - flat file |
| src/app/dashboard/index.tsx | /dashboard | Yes - index file |
| src/app/dashboard/settings.tsx | /dashboard/settings | Yes - nested flat file |
| src/app/layout.tsx | - | No - reserved name |
Define routes with folders and page files inside them.
Match URL segments with dynamic parameters and catch-alls.
Write routes as .mdx or .md files.
Navigate between routes with Link, useNavigate, and prefetching.
Create your first pages and wrap them in shared layouts.
Learn how a Bini.js project is organized and what each folder contains.
Flat files in src/app directly create URL routes without needing a folder.
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 Path | URL |
|---|---|
| src/app/page.tsx | / |
| src/app/about.tsx | /about |
| src/app/contact.tsx | /contact |
| src/app/blog.tsx | /blog |
A file in src/app directly maps to a URL. The file must default-export a React component.
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.
| Approach | File Path | URL |
|---|---|---|
| File-based | src/app/about.tsx | /about |
| Folder-based | src/app/about/page.tsx | /about |
| File-based | src/app/dashboard.tsx | /dashboard |
| Folder-based | src/app/dashboard/page.tsx | /dashboard |
index.tsx inside a folder maps to that folder's URL. It is the file-based equivalent of page.tsx in the same folder.
index.tsx and page.tsx produce the same URL for a folder. Pick one pattern and stay consistent.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.
| Extension | Pages | Routing files |
|---|---|---|
| .tsx | Yes | Yes |
| .jsx | Yes | Yes |
| .ts | Yes | Yes |
| .js | Yes | Yes |
| .mdx | Yes | No |
| .md | Yes | No |
about.tsx and about.jsx both exist, the router throws a route conflict. Delete one of them.These file names are special files, not routes. They configure a folder or a route but never become a URL on their own.
| File Name | Creates URL? | Reason |
|---|---|---|
| page.tsx | Yes - via folder | Defines the page for a folder |
| layout.tsx | No | Shared layout for a folder |
| loading.tsx | No | Loading UI |
| error.tsx | No | Error UI |
| not-found.tsx | No | 404 UI |
| template.tsx | No | Template wrapper |
| default.tsx | No | Parallel route fallback |
| global-error.tsx | No | Global error fallback |
A project using file-based routes alongside a folder-based route and a special file.
| File Path | URL | Creates URL? |
|---|---|---|
| src/app/page.tsx | / | Yes |
| src/app/about.tsx | /about | Yes - flat file |
| src/app/contact.tsx | /contact | Yes - flat file |
| src/app/dashboard/index.tsx | /dashboard | Yes - index file |
| src/app/dashboard/settings.tsx | /dashboard/settings | Yes - nested flat file |
| src/app/layout.tsx | - | No - reserved name |
Define routes with folders and page files inside them.
Match URL segments with dynamic parameters and catch-alls.
Write routes as .mdx or .md files.
Navigate between routes with Link, useNavigate, and prefetching.
Create your first pages and wrap them in shared layouts.
Learn how a Bini.js project is organized and what each folder contains.