Custom loading states with loading.tsx - a Suspense boundary that shows instantly on navigation while layouts stay visible.
Create a loading.tsx file to show a custom fallback while a page loads. It becomes the Suspense fallback for that segment. Parent layouts stay mounted - only the page slot shows the loading UI.
| File | Purpose |
|---|---|
| src/app/loading.tsx | Global loading fallback |
| src/app/blog/loading.tsx | Blog-specific loading |
| src/app/dashboard/loading.tsx | Dashboard-specific loading |
loading.tsx does not create a URL. Nearest-wins - the closest file to the navigated page is used. Layouts remain interactive while content loads.loading.tsx wraps the page in a Suspense boundary. On navigation the fallback shows immediately while the page chunk loads.
Place loading.tsx at the root of app for a default fallback for all routes that do not define their own.
Route-specific loading by placing loading.tsx in subdirectories. Closest file to the page wins.
| Navigation | Loading UI Used |
|---|---|
| / → /about | src/app/loading.tsx - global |
| / → /blog | src/app/blog/loading.tsx |
| / → /blog/hello-world | src/app/blog/[slug]/loading.tsx |
| / → /dashboard | src/app/dashboard/loading.tsx |
Skeletons show approximate layout and usually feel better than a spinner alone.
Loading UI is shown inside the layout hierarchy. Headers, sidebars, and nav stay visible and interactive while only the page content shows the fallback.
Build branded spinners that match your design system.
If no loading.tsx exists, Bini.js uses a built-in spinner. It follows the dark class and prefers-color-scheme.
Write routes as .mdx or .md files.
Catch render errors and show a fallback UI.
Handle unmatched URLs with a custom 404 page.
Wrap each page individually inside the layout chain.
Create your first pages and wrap them in shared layouts.
Define routes with folders and page files inside them.
Custom loading states with loading.tsx - a Suspense boundary that shows instantly on navigation while layouts stay visible.
Create a loading.tsx file to show a custom fallback while a page loads. It becomes the Suspense fallback for that segment. Parent layouts stay mounted - only the page slot shows the loading UI.
| File | Purpose |
|---|---|
| src/app/loading.tsx | Global loading fallback |
| src/app/blog/loading.tsx | Blog-specific loading |
| src/app/dashboard/loading.tsx | Dashboard-specific loading |
loading.tsx does not create a URL. Nearest-wins - the closest file to the navigated page is used. Layouts remain interactive while content loads.loading.tsx wraps the page in a Suspense boundary. On navigation the fallback shows immediately while the page chunk loads.
Place loading.tsx at the root of app for a default fallback for all routes that do not define their own.
Route-specific loading by placing loading.tsx in subdirectories. Closest file to the page wins.
| Navigation | Loading UI Used |
|---|---|
| / → /about | src/app/loading.tsx - global |
| / → /blog | src/app/blog/loading.tsx |
| / → /blog/hello-world | src/app/blog/[slug]/loading.tsx |
| / → /dashboard | src/app/dashboard/loading.tsx |
Skeletons show approximate layout and usually feel better than a spinner alone.
Loading UI is shown inside the layout hierarchy. Headers, sidebars, and nav stay visible and interactive while only the page content shows the fallback.
Build branded spinners that match your design system.
If no loading.tsx exists, Bini.js uses a built-in spinner. It follows the dark class and prefers-color-scheme.
Write routes as .mdx or .md files.
Catch render errors and show a fallback UI.
Handle unmatched URLs with a custom 404 page.
Wrap each page individually inside the layout chain.
Create your first pages and wrap them in shared layouts.
Define routes with folders and page files inside them.