Skip to content

React Router

In one line

React Router is a library that enables navigation between different pages/views in a React single-page application.

In simple words

React Router is the de facto routing library for React. It lets you map URL paths to components, so navigating to /about renders your About component, /users/42 renders a user profile, etc. — all without full page reloads.

Core components: <BrowserRouter> wraps the app, <Routes> contains route definitions, <Route path="/about" element={<About />} /> maps a path to a component, <Link to="/about"> creates navigation links, and useParams() / useNavigate() are Hooks for reading route params and navigating programmatically.

React Router keeps the URL in sync with what's rendered, supports nested routes, dynamic parameters, query strings, and lazy-loaded route components. It is a separate package (react-router-dom) — React itself does not include routing.

Example

jsx
<BrowserRouter>
  <Routes>
    <Route path="/" element={<Home />} />
    <Route path="/about" element={<About />} />
    <Route path="/users/:id" element={<UserProfile />} />
  </Routes>
</BrowserRouter>

Three routes are defined. Navigating to /users/42 renders UserProfile, which can read the id param with useParams().

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary