Setting Up React Router
Learn about installing the React Router.
In this section, we are going to install React Router with the corresponding TypeScript types by carrying out the following steps:
Make sure the frontend project is open in Visual Studio Code and enter the following command to install React Router in the terminal:
Press + to interact
npm install react-router-dom
Note: Make sure react-router-dom version 6+ has been installed and listed in
package.json
. If version 5 has been installed, then version 6 can be installed by runningnpm install react-router-dom@next
.
React router has a peer dependency on the
history
package, so let’s install this using the terminal as well:
Press + to interact
npm install history
A peer dependency is a dependency that is not automatically installed by npm. This is ...
Get hands-on with 1400+ tech skills courses.