Installing React Router
React Router
is a standard library for routing in React apps. It allows navigation between different components (pages) using URLs.
To install:
npm install react-router-dom
Make sure to wrap your app with BrowserRouter
from react-router-dom
in main.jsx
or index.js
:
import { BrowserRouter } from "react-router-dom";
ReactDOM.createRoot(document.getElementById('root')).render(
<BrowserRouter>
<App />
</BrowserRouter>
);