Pre-render your Bini.js app to static HTML, ready for any static host.
Pre-rendering is built into the production build. Every route that can be rendered is rendered to HTML during vite build and written into dist/, so the first paint delivers real content while React hydrates in the background.
There is no separate export command and no export mode to enable. The same build that bundles your client also produces the pre-rendered pages.
During the build, each of the following steps runs in order:
dist/.404.html.Export staticParams from a dynamic page to declare which URLs should be pre-rendered. It works independently of link crawling, so you can guarantee coverage of every known parameter.
Each object is substituted into the route pattern. Named segments such as :slug accept a string or number. A trailing * or ** accepts the '*' key, as either an array of segments or a string that is split on /.
staticParams that no rendered page links to will only get a shell page. To pre-render it as full HTML, list its URLs in staticParams or link to it from a rendered page.Opt a page out of server rendering by exporting prerender = false:
A shell page is still written at that URL, but the SSR renderer is never called for it. Use this for pages that only make sense on the client, such as authenticated dashboards or views that depend on browser APIs.
Build your app for production. The client, the server bundle, and all pre-rendered HTML are produced in a single pass.
To serve the build on a Node.js host, use the start command. It runs the production server, which serves the pre-rendered pages and the compiled API together:
| Command | Purpose |
|---|---|
npm run build | Builds the client, builds the server bundle, and pre-renders every route to dist/. |
npm run start | Serves the built app on a Node.js server, including API routes. |
Each route is written as its own folder with an index.html. Highlighted files were produced by crawling or expanded from staticParams. The [slug] and [...slug] folders are shell fallbacks for dynamic routes that were never pre-rendered.
staticParams, is written as full HTML. Everything else falls back to a shell page.After rendering static routes and any staticParams URLs, the build reads each rendered page for internal links and renders those URLs as well:
This repeats until no new URLs are discovered. Some routes cannot be rendered server-side - those with prerender = false, client-only routes with data exports such as loader, and dynamic patterns that no page links to and that are not listed in staticParams. Each of those receives a shell page with an empty #root and this marker in <head>:
The marker script only sets a flag. The client entry decides how to mount the app based on it:
window.__BINI_SHELL__ === true, or #root is empty, call createRoot(root).render(<App />).hydrateRoot(root, <App />).A pre-rendered page already contains its markup, so hydrating it attaches the client app without a second render. A shell page has an empty #root, so attempting to hydrate it would fail - hence the flag.
404.html is always written to dist/. What goes inside depends on your app:
| Situation | What gets written to 404.html |
|---|---|
src/app/not-found.tsx | Your custom not-found page, pre-rendered to HTML. |
| No custom not-found file | The built-in 404 page. |
| Rendering /404 fails | A shell page - not counted as a build failure. |
The Web build can be served directly from any static host. Both static and dynamic routes work:
| Host | Static routes | Dynamic routes |
|---|---|---|
| GitHub Pages | ✓ pre-rendered | ✓ crawled + pre-rendered, shell fallback |
| AWS S3 + CloudFront | ✓ pre-rendered | ✓ crawled + pre-rendered, shell fallback |
| Firebase Hosting | ✓ pre-rendered | ✓ crawled + pre-rendered, shell fallback |
| Surge.sh | ✓ pre-rendered | ✓ crawled + pre-rendered, shell fallback |
Deploy to GitHub Pages. If your site is served under a subpath, set base in vite.config.ts first:
Build the app, then push the contents of dist/ to your GitHub Pages branch (or upload them through the GitHub Pages UI).
Where to deploy a Bini.js app.
Run the production server for Node.js hosting.
Platform-specific deployment notes.
How routes map to pages in the app directory.
Pre-render your Bini.js app to static HTML, ready for any static host.
Pre-rendering is built into the production build. Every route that can be rendered is rendered to HTML during vite build and written into dist/, so the first paint delivers real content while React hydrates in the background.
There is no separate export command and no export mode to enable. The same build that bundles your client also produces the pre-rendered pages.
During the build, each of the following steps runs in order:
dist/.404.html.Export staticParams from a dynamic page to declare which URLs should be pre-rendered. It works independently of link crawling, so you can guarantee coverage of every known parameter.
Each object is substituted into the route pattern. Named segments such as :slug accept a string or number. A trailing * or ** accepts the '*' key, as either an array of segments or a string that is split on /.
staticParams that no rendered page links to will only get a shell page. To pre-render it as full HTML, list its URLs in staticParams or link to it from a rendered page.Opt a page out of server rendering by exporting prerender = false:
A shell page is still written at that URL, but the SSR renderer is never called for it. Use this for pages that only make sense on the client, such as authenticated dashboards or views that depend on browser APIs.
Build your app for production. The client, the server bundle, and all pre-rendered HTML are produced in a single pass.
To serve the build on a Node.js host, use the start command. It runs the production server, which serves the pre-rendered pages and the compiled API together:
| Command | Purpose |
|---|---|
npm run build | Builds the client, builds the server bundle, and pre-renders every route to dist/. |
npm run start | Serves the built app on a Node.js server, including API routes. |
Each route is written as its own folder with an index.html. Highlighted files were produced by crawling or expanded from staticParams. The [slug] and [...slug] folders are shell fallbacks for dynamic routes that were never pre-rendered.
staticParams, is written as full HTML. Everything else falls back to a shell page.After rendering static routes and any staticParams URLs, the build reads each rendered page for internal links and renders those URLs as well:
This repeats until no new URLs are discovered. Some routes cannot be rendered server-side - those with prerender = false, client-only routes with data exports such as loader, and dynamic patterns that no page links to and that are not listed in staticParams. Each of those receives a shell page with an empty #root and this marker in <head>:
The marker script only sets a flag. The client entry decides how to mount the app based on it:
window.__BINI_SHELL__ === true, or #root is empty, call createRoot(root).render(<App />).hydrateRoot(root, <App />).A pre-rendered page already contains its markup, so hydrating it attaches the client app without a second render. A shell page has an empty #root, so attempting to hydrate it would fail - hence the flag.
404.html is always written to dist/. What goes inside depends on your app:
| Situation | What gets written to 404.html |
|---|---|
src/app/not-found.tsx | Your custom not-found page, pre-rendered to HTML. |
| No custom not-found file | The built-in 404 page. |
| Rendering /404 fails | A shell page - not counted as a build failure. |
The Web build can be served directly from any static host. Both static and dynamic routes work:
| Host | Static routes | Dynamic routes |
|---|---|---|
| GitHub Pages | ✓ pre-rendered | ✓ crawled + pre-rendered, shell fallback |
| AWS S3 + CloudFront | ✓ pre-rendered | ✓ crawled + pre-rendered, shell fallback |
| Firebase Hosting | ✓ pre-rendered | ✓ crawled + pre-rendered, shell fallback |
| Surge.sh | ✓ pre-rendered | ✓ crawled + pre-rendered, shell fallback |
Deploy to GitHub Pages. If your site is served under a subpath, set base in vite.config.ts first:
Build the app, then push the contents of dist/ to your GitHub Pages branch (or upload them through the GitHub Pages UI).
Where to deploy a Bini.js app.
Run the production server for Node.js hosting.
Platform-specific deployment notes.
How routes map to pages in the app directory.