React Router DOM (version 7.14.1) provides declarative routing for React web applications. It currently serves as a compatibility layer for projects migrating from React Router v6 to v7, re-exporting all components and hooks from the `react-router` package. While actively maintained with frequent minor and patch releases, its primary purpose is to facilitate migration, and users are encouraged to eventually remove it and import directly from `react-router` in v7 projects.
npm install react-router-domVerified import paths — ran on the pinned version, not inferred.
This example demonstrates a basic React application using `BrowserRouter` to set up client-side routing, defining different paths with `Routes` and `Route` components, and navigating between them with `Link`.
Migrate your imports from `react-router-dom` to `react-router` (e.g., `import { BrowserRouter } from 'react-router'`) and remove `react-router-dom` from your `package.json`.Follow the migration guide for React Router v7 and import directly from `react-router`. Remove `react-router-dom` from your project dependencies.
Ensure `react` and `react-dom` are installed at version `>=18` in your project's `package.json`.
Upgrade your Node.js environment to version `20.0.0` or later.
If migrating to v7, ensure all imports have been changed to `react-router`. Otherwise, install `react-router-dom` via `npm install react-router-dom` or `yarn add react-router-dom`.
Wrap your application's root component or the section using routing components with `<BrowserRouter>`. For example: `<BrowserRouter><App/></BrowserRouter>`.
Upgrade `react` and `react-dom` in your `package.json` to version `18.0.0` or higher: `npm install react@^18 react-dom@^18`.
No dependency data recorded yet.