This example demonstrates using rsbuild-plugin-react-router in SPA (Single Page Application) mode with ssr: false.
SPA mode disables server-side rendering, generating a static index.html that can be deployed to any static hosting service like:
- Netlify
- Vercel (static)
- GitHub Pages
- AWS S3 + CloudFront
- Any static file server
- ⚡️ Client-side routing only
- 📦 Static build output (no server required)
- 🔄 Pre-rendered
index.htmlwith hydration data - 🔒 TypeScript by default
- 🎉 TailwindCSS for styling
SPA mode is enabled in react-router.config.ts:
import type { Config } from '@react-router/dev/config';
export default {
ssr: false,
} satisfies Config;- No server directory - After build, only
build/client/is generated - Static index.html - Pre-rendered HTML with embedded hydration data
- No manifest requests - Route discovery is set to
initialmode - Client-side only - All data loading happens in the browser
pnpm installStart the development server:
pnpm run devYour application will be available at http://localhost:3001.
Create a production build:
pnpm run buildThis generates static files in build/client/:
build/
└── client/
├── index.html # Pre-rendered entry point
├── static/
│ ├── js/ # JavaScript bundles
│ └── css/ # CSS files
└── ...
Serve the static files locally:
pnpm run startOr deploy the build/client/ directory to any static hosting service.
The e2e tests verify SPA-specific behavior:
pnpm run test:e2eTests verify:
- ✅
index.htmlis generated with hydration data - ✅ No server directory after build
- ✅ Client-side navigation works
- ✅ No
/__manifestrequests (route discovery isinitial) - ✅ Deep linking works
- ✅ Browser back/forward navigation works
Choose SPA mode when:
- You need static hosting only
- SEO is not a primary concern
- Initial page load time is acceptable
- You want simpler deployment
Choose SSR mode when:
- SEO is important
- You need faster initial page loads
- You have server-side data requirements
Built with ❤️ using React Router and Rsbuild.