Static Export
Pre-render your Bini.js app to static HTML with bini-ssg, ready for any static host.
bini-ssg pre-renders every route — static and dynamic — to static HTML as part of npm run build. There is no separate export command or export mode. The output is real server-rendered markup, not a client-only shell, ready for GitHub Pages, S3, Firebase, Surge, and any other static host.
bini-ssg — they package the same routes into a native binary instead.How It Works
bini-ssg is a Vite build plugin that runs during vite build. It:
- Reads your route list from
bini-router'sgenerateRouteManifest() - Calls your
render()function for every static route - Creates shell pages for dynamic routes with a hydration marker
- Writes one
index.htmlper route into your output directory
Your render() Function
The render() function is exported from src/main.tsx and called by bini-ssg for every static route:
This function uses React 19's renderToPipeableStream under the hood with StaticRouter from React Router, producing real server-rendered HTML.
render() function is already in your project. You only need to modify it if you need custom server rendering logic.Build Command
| Command | When to use |
|---|---|
npm run build | Pre-renders every route to static HTML — GitHub Pages, S3, Firebase, Surge, and any static host |
npm run start | Serves the production build with API routes — Node.js hosts (Railway, Render, Fly.io, VPS) |
npm run build type-checks (TypeScript projects) and then runs vite build. The bini-ssg plugin drives pre-rendering as part of that same build.
Output Structure
Shell Pages & Hydration
For dynamic routes (e.g., /blog/:slug), bini-ssg creates a shell page with a marker script:
Your client entry checks this flag to decide between createRoot and hydrateRoot:
#root div against your component tree.404 Handling
You can enable 404.html generation with the fallback option:
| Situation | What gets written to 404.html |
|---|---|
src/app/not-found.tsx exists | Your custom not-found page is pre-rendered to HTML |
| No custom not-found file | Built-in 404 page is used |
fallback is false. Enable it to generate 404.html for static hosts that support it.Works on Any Fully Static Host
| Host | Static routes | Dynamic routes |
|---|---|---|
| GitHub Pages | pre-rendered | shell pages |
| AWS S3 + CloudFront | pre-rendered | shell pages |
| Firebase Hosting | pre-rendered | shell pages |
| Surge.sh | pre-rendered | shell pages |
Complete Example
A full setup for deploying to GitHub Pages with true SSG:
Run npm run build, then push the contents of dist/ to your GitHub Pages branch (or upload them through the GitHub Pages UI).