The first thing we want to do is setup our project to run React Router.
-
Step 1: Install create-react-app
Run the code below in the terminal.
npx create-react-app react-router-demo
Import into project. This will generate a project with several boilerplate codes which comes with the React library.
-
Step 2: Install react-router package
Using npm package manager:
npm install react-router
Using yarn manager:
yarn add react-router
Install React Router Package using npm and yarn package managers.
This should install the latest version of React Router, which is currently React Router 6.
To see the version installed, check the package.json file in the react project.