NPM Star
Collections
  1. Home
  2. Compare
  3. react-router vs react-router-dom
NPM Compare

Compare NPM packages statistics, trends, and features

CollectionsVS Code extensionChrome extensionTermsPrivacyLinkTreeIndiehackersBig Frontendqiuyumi

React Router Core vs React Router DOM: Web Navigation Tools

These packages work together to handle webpage navigation in React applications. React Router is the core routing library containing the main routing logic, while React Router DOM adds specific tools for web browsers. Most web developers only need to install react-router-dom, as it includes react-router as a dependency and provides all the necessary browser-specific components.

React NavigationroutingnavigationreactbrowserURL management

Detailed Comparison

Technical Analysis

featureComparison

Both packages provide client-side routing for React applications. react-router provides the core routing functionality, while react-router-dom provides additional DOM-specific features such as browser history management and HTML5 pushState.

typescriptSupport

Both packages have excellent TypeScript support, with type definitions included in the package.

browserCompatibility

Both packages support modern browsers, including Chrome, Firefox, Safari, Edge, and Internet Explorer 11.

dependencies

react-router-dom depends on react-router, and both packages depend on React.

performance

Both packages have excellent performance, with efficient routing and minimal overhead.

Ecosystem Analysis

frameworkCompatibility

Both packages are compatible with React, and can be used with other frameworks and libraries.

communityActivity

Both packages have an active community, with frequent updates and contributions.

documentationQuality

Both packages have excellent documentation, with clear guides and examples.

maintenanceStatus

Both packages are actively maintained, with regular updates and bug fixes.

Performance Comparison

bundleSizeAnalysis

react-router-dom has a slightly larger bundle size due to the additional DOM-specific features.

runtimePerformance

Both packages have similar runtime performance, with efficient routing and minimal overhead.

loadingTime

Both packages have similar loading times, with react-router-dom being slightly slower due to the additional features.

memoryUsage

Both packages have similar memory usage, with minimal overhead.

Code Examples

Basic Routing with react-router

1import { BrowserRouter, Route, Link } from 'react-router-dom';
2
3function App() {
4  return (
5    <BrowserRouter>
6      <div>
7        <h1>Home</h1>
8        <p><Link to="/about">Learn more</Link></p>
9      </div>
10      <Route path="/about">
11        <h1>About</h1>
12      </Route>
13    </BrowserRouter>
14  );
15}

This example shows how to use react-router-dom to create a basic routing system with a home page and an about page.

Programmatic Navigation with react-router

1import { useHistory } from 'react-router';
2
3function App() {
4  const history = useHistory();
5
6  function handleClick() {
7    history.push('/about');
8  }
9
10  return (
11    <div>
12      <h1>Home</h1>
13      <p><button onClick={handleClick}>Learn more</button></p>
14    </div>
15  );
16}

This example shows how to use react-router to programmatically navigate to a different route using the useHistory hook.

Recommendation

Summary

Both packages are excellent choices for client-side routing in React applications.

Details

  • react-router provides the core routing functionality, while react-router-dom provides additional DOM-specific features.
  • react-router-dom is a better choice for most applications, as it provides more features out of the box.

Similar Packages

reach/router

95%

A routing library built by the original creator of React Router. Focuses on accessibility and simplicity, with built-in focus management for screen readers.

Very similar to React Router but with better accessibility features built-in. Good for projects where accessibility is a top priority.

React Routing

wouter

90%

A tiny router for React that's simpler than React Router. It has a very small size (1KB) and provides basic routing features like path matching and navigation.

Perfect for small to medium projects where you don't need all of React Router's complex features. It uses a similar API to React Router so it's easy to learn if you know React Router.

React Routing

next/router

70%

The built-in router that comes with Next.js framework. Provides file-system based routing and easy page transitions with zero configuration needed.

Great alternative if you're using Next.js. No need to install additional packages, and it's simpler to use because routing is based on your folder structure.

React Routing

universal-router

60%

A simple middleware-style router that can work with any JavaScript framework, not just React. Supports async routes and nested routes.

Good choice if you want a framework-agnostic router that might work across different projects. Simpler than React Router but still powerful.

JavaScript Routing

No README available

No README available

StarsIssuesVersionUpdatedⓘLast publish dateCreatedⓘPackage creation dateSizeⓘMinified + Gzipped size
R
react-router
55,0892377.6.2a month ago11 years agoinstall size 51.4 KB
R
react-router-dom
55,0892377.6.2a month ago9 years agoinstall size 335 B

Dependencies Comparison

react-router

Dependencies

cookie^1.0.1
set-cookie-parser^2.6.0

Dev Dependencies

tsup^8.3.0
react^19.1.0
rimraf^6.0.1
wireit0.14.9
react-dom^19.1.0
typescript^5.1.6
@types/set-cookie-parser^2.4.1

Peer Dependencies

react>=18
react-dom>=18

react-router-dom

Dependencies

react-router7.6.2

Dev Dependencies

tsup^8.3.0
react^19.1.0
wireit0.14.9
react-dom^19.1.0
typescript^5.1.6

Peer Dependencies

react>=18
react-dom>=18

Who's Using These Packages

react-router

builder
builder

Multiplayer game framework

geoplumber
geoplumber

Serve geographic data from R and consume with scalable front end.

vertex
vertex

Node/React/Redux blog. Dockerized, Isomorphic, has Auth. Will be decentralized.

arranger
arranger

Data portal API and component generation

react-router-dom

builder
builder

Multiplayer game framework

lore
lore

Respectfully opinionated convention-driven framework for building React applications. Built on React, Webpack, Redux, and React Router.

geoplumber
geoplumber

Serve geographic data from R and consume with scalable front end.

arranger
arranger

Data portal API and component generation

python-tracer
python-tracer

Интерактивный тренажёр по Питону