React Router
React Router is the most popular library for adding client-side routing to a React app, letting you map URLs to different components so users can navigate between 'pages' without full page reloads.
React
React itself has no built-in concept of pages or URLs. React Router fills that gap: you declare routes that connect a URL path to a component, and it swaps in the right component as the URL changes, all without reloading the browser.
You navigate using the <Link> component instead of a plain <a> tag, which updates the URL without a full reload. Routes can include URL parameters (like /users/:id) so the same component can display different data based on the address.
Examples
JSX — Clicking the About link changes the URL to /about and renders the About component without a full page reload.
import { BrowserRouter, Routes, Route, Link } from "react-router-dom";
function App() {
return (
<BrowserRouter>
<Link to="/about">About</Link>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/about" element={<About />} />
</Routes>
</BrowserRouter>
);
}