StackShareStackShare
Follow on
StackShare

Discover and share technology stacks from companies around the world.

Follow on

© 2025 StackShare. All rights reserved.

Product

  • Stacks
  • Tools
  • Feed

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Service
  1. Stackups
  2. Application & Data
  3. Languages
  4. Npm Packages
  5. react-router vs react-router-dom

react-router vs react-router-dom

OverviewComparisonAlternatives

Overview

react-router-dom
react-router-dom
Stacks3.6K
Followers6
Votes0
react-router
react-router
Stacks1.2K
Followers5
Votes0

react-router vs react-router-dom: What are the differences?

Introduction

When working with React applications that involve routing, developers often come across two popular libraries: react-router and react-router-dom. While both these libraries serve the same purpose of handling routing in React applications, there are subtle differences between them that can impact how you structure your routes and components.

  1. Importing: One key difference between react-router and react-router-dom is how they are imported in your project. The react-router package is the core routing library and should be used in your application logic, while react-router-dom provides DOM bindings for React Router and should be used in your components.

  2. BrowserRouter vs. HashRouter: In react-router, the BrowserRouter is used for handling routing with the browser's history API, while in react-router-dom, the HashRouter is utilized for routes that use the hash portion of the URL. This can affect how your routes are rendered and accessed based on the browser's capabilities.

  3. Route components: Another difference lies in how you define your routes using Route components. With react-router, you have access to more low-level route components such as Route, Switch, and Redirect. In contrast, react-router-dom provides higher-level components like Route and Switch that are more tailored for browser applications.

  4. Link component: The Link component in react-router-dom is used to navigate to different routes in your application. This is a key difference from react-router, where the Link component is not present, making it necessary to use the NavLink component for navigation functionality.

  5. MemoryRouter: react-router-dom includes the MemoryRouter component, which is not present in react-router. This component allows you to keep the history of your routes in memory without affecting the browser's URL. It can be useful for testing and scenarios where you don't want to change the actual URL.

  6. Installation: A significant difference between react-router and react-router-dom is how you install them in your project. While react-router-dom is typically installed along with react-router, you only need to install react-router-dom to use its functionalities, as it includes everything from the react-router package.

In Summary, react-router and react-router-dom offer similar functionalities for routing in React applications, but differ in aspects such as import methods, route components, navigation mechanisms, and additional features like MemoryRouter. Understanding these differences can help you choose the right library based on your project requirements.

Share your Stack

Help developers discover the tools you use. Get visibility for your team's tech choices and contribute to the community's knowledge.

View Docs
CLI (Node.js)
or
Manual

Detailed Comparison

react-router-dom
react-router-dom
react-router
react-router

DOM bindings for React Router.

A complete routing library for React.

Statistics
Stacks
3.6K
Stacks
1.2K
Followers
6
Followers
5
Votes
0
Votes
0

What are some alternatives to react-router-dom, react-router?

typescript

typescript

TypeScript is a language for application scale JavaScript development.

eslint

eslint

An AST-based pattern checker for JavaScript.

react

react

React is a JavaScript library for building user interfaces.

@types/node

@types/node

TypeScript definitions for Node.js.

prettier

prettier

Prettier is an opinionated code formatter.

react-dom

react-dom

React package for working with the DOM.

jest

jest

Delightful JavaScript Testing.

express

express

Fast, unopinionated, minimalist web framework.

mocha

mocha

Simple, flexible, fun test framework.

webpack

webpack

Packs CommonJs/AMD modules for the browser. Allows to split your codebase into multiple bundles, which can be loaded on demand. Support loaders to preprocess files, i.e. json, jsx, es7, css, less, ... and your custom stuff.

Related Comparisons

Bootstrap
Materialize

Bootstrap vs Materialize

Laravel
Django

Django vs Laravel vs Node.js

Bootstrap
Foundation

Bootstrap vs Foundation vs Material UI

Node.js
Spring Boot

Node.js vs Spring-Boot

Liquibase
Flyway

Flyway vs Liquibase