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.
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 handling browser history and linking.
Both packages have excellent TypeScript support, with clear type definitions and documentation.
Both packages support modern browsers, including Chrome, Firefox, Safari, and Edge.
react-router-dom depends on react-router, and both packages have minimal dependencies.
Both packages have excellent performance, with efficient routing and minimal overhead.
Both packages are designed specifically for React applications.
Both packages have an active community, with frequent updates and issues resolved quickly.
Both packages have excellent documentation, with clear guides and API references.
Both packages are actively maintained by the React Router team, with regular updates and bug fixes.
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.
1import { StaticRouter } from 'react-router';
2
3function App() {
4 return (
5 <StaticRouter>
6 <div>
7 <h1>Home</h1>
8 </div>
9 </StaticRouter>
10 );
11}
This example shows how to use react-router for server-side rendering, using the StaticRouter component.
Both packages are excellent choices for client-side routing in React applications. react-router provides the core routing functionality, while react-router-dom provides additional DOM-specific features.
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 RoutingA 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 RoutingThe 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 RoutingA 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 RoutingNo README available
Starter files for learning React.js with React for Beginners
Multiplayer game framework
Respectfully opinionated convention-driven framework for building React applications. Built on React, Webpack, Redux, and React Router.
The VLINGO XOOM Designer to guide you in rapid delivery of low-code to full-code Reactive, Event-Driven Microservices and Applications using DOMA, DDD, and other approaches.
Serve geographic data from R and consume with scalable front end.
Starter files for learning React.js with React for Beginners
Multiplayer game framework
Respectfully opinionated convention-driven framework for building React applications. Built on React, Webpack, Redux, and React Router.
The VLINGO XOOM Designer to guide you in rapid delivery of low-code to full-code Reactive, Event-Driven Microservices and Applications using DOMA, DDD, and other approaches.
Serve geographic data from R and consume with scalable front end.