Skip to main content

Picking a Mode

React Router is a multi-strategy router for React. There are three primary ways, or “modes”, to use it in your app. The features available in each mode are additive, so moving from Declarative to Data to Framework simply adds more features at the cost of architectural control.
Pick your mode based on how much control or how much help you want from React Router.

The Three Modes

The mode depends on which “top level” router API you’re using:
Enables basic routing features like matching URLs to components, navigating around the app, and providing active states.
import { BrowserRouter } from "react-router";

ReactDOM.createRoot(root).render(
  <BrowserRouter>
    <App />
  </BrowserRouter>
);

Mode Comparison

FeatureDeclarativeDataFramework
URL Matching
Navigation
Active States
Data Loading
Actions
Pending States
Type Safety
Code Splitting
SSR/SSGManualManualBuilt-in
Setup ComplexityLowMediumHigher
Architectural ControlFullHighMedium

Decision Guide

Every mode supports any architecture and deployment target, so the question isn’t really about if you want SSR, SPA, etc. It’s about how much you want to do yourself.
1
Choose Framework Mode if you:
2
  • Are too new to have an opinion
  • Are considering Next.js, Solid Start, SvelteKit, Astro, TanStack Start, etc. and want to compare
  • Just want to build something with React
  • Might want to server render, might not
  • Are coming from Remix (React Router v7 is the “next version” after Remix v2)
  • Are migrating from Next.js
  • 4
    Choose Data Mode if you:
    5
  • Want data features but also want to have control over bundling, data, and server abstractions
  • Started a data router in v6.4 and are happy with it
  • Have your own build setup and don’t want to add a Vite plugin
  • 7
    Choose Declarative Mode if you:
    8
  • Want to use React Router as simply as possible
  • Are coming from v6 and are happy with <BrowserRouter>
  • Have a data layer that either skips pending states (like local first, background data replication/sync) or has its own abstractions for them
  • Are coming from Create React App (you may want to consider framework mode though)
  • Examples By Mode

    import { BrowserRouter, Routes, Route, Link } from "react-router";
    
    function App() {
      return (
        <BrowserRouter>
          <nav>
            <Link to="/">Home</Link>
            <Link to="/about">About</Link>
          </nav>
          <Routes>
            <Route index element={<Home />} />
            <Route path="about" element={<About />} />
          </Routes>
        </BrowserRouter>
      );
    }
    

    Can I Switch Modes Later?

    Yes! The modes are designed to be upgrade paths:
    1
    Declarative → Data
    2
    Replace <BrowserRouter> with createBrowserRouter and <RouterProvider>. You can migrate routes incrementally by adding loaders and actions.
    3
    Data → Framework
    4
    Add the Vite plugin and move your route configuration to routes.ts. You get instant type safety and code splitting.
    5
    Framework → Data
    6
    Remove the Vite plugin and convert your route modules to plain route objects. You keep all the data loading features.
    Start simple and upgrade as your needs grow. Each mode builds on the previous one.

    Build docs developers (and LLMs) love