Framework Mode
Framework Mode is the full-featured way to use React Router. It wraps Data Mode with a Vite plugin to add type-safe routing, intelligent code splitting, and flexible rendering strategies (SPA, SSR, SSG).Quick Start
What You Get
Framework Mode provides:- Type Safety: Auto-generated types for params, loader data, and actions
- Code Splitting: Automatic route-based code splitting
- SSR/SPA/SSG: Choose your rendering strategy per route
- File-based or Config-based Routing: Use what works for your team
- Optimized Builds: Production-ready bundling with Vite
- Development Server: Fast HMR and instant feedback
Project Structure
A typical Framework Mode project looks like this:Configuring Routes
- File-based (Recommended)
- Config-based
- Hybrid
Use the file system to define your routes with File naming conventions:
flatRoutes():Route Modules
Route modules define behavior for each route using exports:Type Safety
Framework Mode automatically generates types for your routes:Types are generated automatically on file changes during development. No manual type definitions needed!
Nested Routes and Layouts
Data Loading Strategies
- Server (SSR)
- Client Only
- Hybrid
Rendering Strategies
Configure inreact-router.config.ts:
Vite Plugin Setup
The plugin is configured invite.config.ts:
Next Steps
Framework Mode gives you the full power of React Router with the best developer experience.