React Router System Requirements and Compatibility
Exactly what React Router 8 needs to run, how that compares with v7 and v6, and which bundlers, browsers, operating systems and hosts work.
Read MoreReact Router installation takes less than a minute once you know which path fits your project. This walkthrough covers all of them: adding React Router to an app you already have, starting a brand-new app in Framework Mode, and installing the package offline from the file on our download page. Every command below was run against React Router 8.5.3, the current release.
If you only need the short version: open a terminal in your React project and run npm i react-router. Everything else on this page explains what that command needs, what to do if you cannot reach npm, and how to check that it worked.
React Router 8 raised its minimum requirements. Installing it on an older stack is the number one cause of install errors, so spend thirty seconds on this first.
node -v. You need 22.22.0 or newer. If you see v20 or v18, install a current Node.js LTS release first (a version manager such as nvm, fnm or Volta makes this easy).npm ls react. React Router 8 needs React and React DOM 19.2.7 or newer.Still on React 18? Install React Router 7 instead with npm i react-router@7. Version 7 is still maintained and supports React 18. You can move to v8 later, after upgrading React.
For a full table of supported runtimes, bundlers and browsers, see React Router system requirements and compatibility.
This is the most common case. You already have a React project, perhaps created with Vite, and you want pages and URLs.
The right folder is the one that contains package.json. In VS Code, the built-in terminal opens there by default.
Pick the line for your package manager:
npm i react-router
pnpm add react-router
yarn add react-router
bun add react-router
The package manager downloads React Router from its registry and adds a line like "react-router": "^8.5.3" to the dependencies section of package.json.
Open your entry file (usually src/main.jsx or src/main.tsx) and render <BrowserRouter> around the app:
import { createRoot } from "react-dom/client";
import { BrowserRouter } from "react-router";
import App from "./App";
createRoot(document.getElementById("root")).render(
<BrowserRouter>
<App />
</BrowserRouter>
);
That is Declarative Mode, the simplest of the three modes. If you would rather use loaders and actions without a framework, use createBrowserRouter and <RouterProvider> instead (Data Mode). Note that in v8 RouterProvider is imported from react-router/dom.
import { Routes, Route, Link } from "react-router";
function Home() { return <h1>Home</h1>; }
function About() { return <h1>About</h1>; }
export default function App() {
return (
<>
<nav>
<Link to="/">Home</Link> | <Link to="/about">About</Link>
</nav>
<Routes>
<Route path="/" element={<Home />} />
<Route path="about" element={<About />} />
</Routes>
</>
);
}
Run npm run dev, open the local URL Vite prints (usually http://localhost:5173) and click between the two links. The URL changes and the heading swaps without a page reload. React Router is installed and working.
If you are starting from scratch and want server rendering, data loading, type-safe routes and code splitting set up for you, let the official starter create the project.
npx create-react-router@latest my-app
Other package managers have equivalents: pnpm create react-router@latest my-app, yarn create react-router my-app or bunx create-react-router@latest my-app. The tool asks a couple of questions (such as whether to initialise Git and install dependencies) and then writes the project.
cd my-app
npm i
npm run dev
Open http://localhost:5173. You will see the starter's welcome page, rendered on the server and then hydrated in the browser.
app/routes.ts lists your routes with helpers like index() and route().app/root.tsx is the HTML shell and top-level layout.app/routes/ holds route modules. Each can export a loader, an action, meta and a default component.react-router.config.ts controls options such as turning server rendering off for a pure SPA.The starter installs react-router along with the Framework Mode tooling packages @react-router/dev, @react-router/node and @react-router/serve. Keep these on the same version as react-router when you upgrade.
Some machines cannot reach the npm registry: locked-down company laptops, air-gapped build servers, classrooms with filtered networks. For those, download the package once and install it from the file.
Our download page provides react-router-8.5.3.tgz, the unmodified tarball published to npm. It is about 650 KB and contains the compiled library, type definitions, the license, the changelog and the bundled docs.
Before installing any file you downloaded, confirm it has not been altered. Compare the result with the SHA-256 value shown on the download page:
# macOS and Linux
shasum -a 256 react-router-8.5.3.tgz
# Windows PowerShell
Get-FileHash react-router-8.5.3.tgz -Algorithm SHA256
If the values match, the file is byte-for-byte identical to the package on npm. If they do not, delete the file and download it again.
Move the file into your project folder, then run:
npm i ./react-router-8.5.3.tgz
npm records it in package.json as "react-router": "file:react-router-8.5.3.tgz". Keep the file in the project (or in a shared folder) so teammates and CI can install it too. For pnpm use pnpm add ./react-router-8.5.3.tgz; for Yarn use yarn add file:./react-router-8.5.3.tgz.
Heads-up: React Router 8.5.3 itself depends on two small packages, cookie-es and @remix-run/route-pattern. On a fully offline machine you will also need those from an internal registry mirror or an npm cache. On most company networks that block only the public internet, an internal mirror already provides them.
All four package managers install the same React Router package, but a few details differ:
node_modules layout. Packages can only import what they declare, which is good for catching mistakes. React Router 8 declares React's type packages as optional peer dependencies, so TypeScript projects should add @types/react and @types/react-dom themselves.yarn dlx @yarnpkg/sdks vscode or switch to nodeLinker: node-modules in .yarnrc.yml.bun.lock file. Use bun run dev to start Vite. Framework Mode builds still use Vite under the hood.Whichever you choose, commit the lockfile it creates so every teammate and your CI server install exactly the same version.
React Router is written in TypeScript and ships its own type definitions, so there is nothing extra to install for the router itself. If your project uses TypeScript, make sure React's types are present too:
npm i -D @types/react @types/react-dom
In Declarative and Data modes you get full autocomplete for components, hooks and route objects right away. In Framework Mode, the dev server also generates types for each route in a hidden .react-router/types folder, so params and loaderData are typed for that exact route. Run npx react-router typegen if your editor ever shows stale route types.
Three quick checks confirm a good install:
npm ls react-router should print react-router@8.5.3 (or the version you chose). If it prints (empty), the install went to a different folder.react-router should appear under dependencies, not devDependencies.This almost always means your React version is older than React Router 8 allows. Either upgrade with npm i react@latest react-dom@latest or install v7 with npm i react-router@7. Avoid --force and --legacy-peer-deps: they hide the conflict and the app fails at runtime instead.
Your Node.js version is below 22.22.0. Upgrade Node.js, delete node_modules and install again.
You are following a tutorial written for v6 or v7. In v8 that package no longer exists. Change imports to react-router, and import RouterProvider or HydratedRouter from react-router/dom.
A component that uses a router hook is rendered outside <BrowserRouter> or <RouterProvider>. Move the router higher, usually to main.jsx.
More errors and their fixes are in React Router not working? Common errors and fixes.
| Your situation | Command | Mode you get |
|---|---|---|
| Existing Vite or CRA-style app | npm i react-router | Declarative or Data |
| New full-stack app | npx create-react-router@latest my-app | Framework |
| No access to npm | npm i ./react-router-8.5.3.tgz | Declarative or Data |
| Project still on React 18 | npm i react-router@7 | Any (v7) |
With React Router installed, the next step is learning the handful of components and hooks you will use every day: Routes, Route, Link, NavLink, Outlet, useNavigate and useParams. Our beginner's walkthrough for using React Router builds a small multi-page app with all of them, and React Router key features explained gives you the bigger picture of what the library can do.
Curious whether the download is safe to use at work? Is React Router safe? License, safety and download sources covers the MIT license, checksums and where each copy comes from.
Get React Router 8.5.3: one npm command, or the verified package download.
DownloadRelated articles
Exactly what React Router 8 needs to run, how that compares with v7 and v6, and which bundlers, browsers, operating systems and hosts work.
Read MoreBuild a small multi-page React app from scratch and learn Routes, Link, NavLink, Outlet, useParams and useNavigate along the way.
Read MoreA plain-English tour of what React Router can do, from nested layouts and URL params to loaders, actions, type-safe routes and server rendering.
Read More