20 entries · 15-question quiz

Building a Multi-Page SPA with React Router

React ↔ Angular reference. React examples use React 19 + TypeScript with React Router's Data Router API (v6.4+, written for v7). Angular examples use modern Angular (standalone components, signals, inject(), @if/@for) with the Angular Router. Version note: In v7, everything is imported from react-router (RouterProvider from react-router/dom). In v6, the same APIs come from react-router-dom. The concepts are identical.

Test yourself

15 questions

  1. 1
    Router Setup: createBrowserRouter and RouterProvider

    createBrowserRouter builds the router from an array of route objects, and <RouterProvider> renders it. Together they enable client-side routing: the URL changes and the matching component renders without a full page reload.

  2. 2
    JSX Routes with createRoutesFromElements

    An alternative way to define routes using <Route> JSX elements, converted into route objects by createRoutesFromElements.

  3. 3
    Navigating with <Link>

    <Link to="..."> performs client-side navigation. It renders an <a> but prevents the full page reload.

  4. 4
    Layouts and Nested Routes with <Outlet />

    A layout route wraps child routes with shared UI (navigation, footer). <Outlet /> marks where the matching child renders.

  5. 5
    Index Routes and Catch-All Routes

    An index route is the default child rendered when the parent's path matches exactly. A catch-all route (path: '*') matches any URL no other route matches.

  6. 6
    Active Links with <NavLink> and end

    <NavLink> is a <Link> that knows whether it's active, for highlighting the current page in navigation.

  7. 7
    Programmatic Navigation with useNavigate

    useNavigate() returns a navigate function for changing routes from code, e.g. after a timer or a button click that does more than link.

  8. 8
    Path Params with useParams

    A dynamic segment (:paramName) in a route path captures part of the URL, and useParams() reads it.

  9. 9
    Absolute vs Relative Paths

    An absolute path starts with / and resolves from the root. A relative path has no leading / and resolves from the current route.

  10. 10
    Query Params with useSearchParams

    useSearchParams() reads and writes the URL's query string (?role=admin), and re-renders the component when it changes.

  11. 11
    Loading Data with loader and useLoaderData

    A route's loader runs before the route renders and fetches its data. The component reads the result with useLoaderData().

  12. 12
    Pending UI with useNavigation

    useNavigation() returns the router's current navigation state, so you can show feedback while a loader or action runs.

  13. 13
    Error Handling with errorElement and useRouteError

    When a loader, action, or component throws, React Router renders the nearest errorElement. Inside it, useRouteError() returns what was thrown.

  14. 14
    Dynamic Loaders and useRouteLoaderData

    Loaders receive { params, request } for dynamic routes. Giving a route an id lets its children read its loader data with useRouteLoaderData(id).

  15. 15
    Mutations with action, <Form>, and redirect

    A route's action handles form submissions. React Router's <Form> collects the inputs and sends them to the action, which usually returns redirect().

  16. 16
    Programmatic Submission with useSubmit

    useSubmit() returns a function that triggers a route action from code, without a <Form>.

  17. 17
    Validation Feedback with useActionData

    If an action returns data instead of a redirect, useActionData() gives the component that data, typically server validation errors.

  18. 18
    Updates Without Navigation: useFetcher

    useFetcher() calls a loader or action without navigating. It's an isolated mini-form for in-place updates.

  19. 19
    Organizing a Router Project

    A folder structure and set of conventions that keep routes, pages, and data logic separate.

  20. 20
    Summary