We can enable routing in a React-based application by using React Router, a package that provides us with specific React components that allow us to set up a complete routing system.
We install that package in our application by typing the following command inside of the application's folder:
npm install --save react-router-dom
React Router provides three packages:
- react-router
- react-router-dom
- react-router-native
The first package provides the core routing components and functionalities. The second one provides specific components for the browser environment, and the third one supports react-native, an environment that maps React components to native mobile UI widgets. Both react-router-dom and react-router-native use react-router functionalities.