Frontend Routing Is Three Objects Tricking the Browser
Understanding routing as a browser con rather than real navigation removes the magic from React Router's API surface. Developers who internalize the navigator-location-history model stop memorizing hooks and start reasoning about navigation state directly, which eliminates a common source of bugs in auth flows and nested layouts.
SPAs serve a single index.html and let JavaScript take over. The URL stops being a resource request and becomes a frontend state label — a signal for which component tree to render. Hash-based routing exploits the anchor's no-refresh behavior, while the History API uses pushState and replaceState to silently rewrite the address bar. Both are an optical illusion: the browser thinks navigation happened, but no HTTP request was sent.
React Router wraps this illusion into navigator (Link, useNavigate, Navigate), location (useLocation, with a hidden state field for cross-page data), and history (the stack that push and replace operate on). Auth-guarded routes chain all three: intercept an unauthenticated visit, navigate to login while stashing the original path in location.state, then navigate back with replace after login succeeds.
Dynamic route matching follows declaration order, not specificity, so concrete paths must precede parameterized ones. Nested routes render into an Outlet slot, building a component tree from a URL pattern. BrowserRouter produces clean, semantic URLs and should be the default unless the hosting environment can't support it.
The mental model shift from 'URL as resource locator' to 'URL as frontend state label' is the single unlock that makes React Router's API feel inevitable rather than arbitrary.
Framing frontend routing as a deliberate browser con — not a feature — strips away the illusion of real navigation and clarifies why every API exists: to manage a stack of fake page transitions.
location.state is an underused mechanism that avoids polluting query strings with internal routing metadata, yet many codebases still stuff redirect targets into ?redirect= params out of habit.
React Router v6's claimed automatic route sorting is a leaky abstraction; the safe, explicit practice of ordering concrete paths first remains the more reliable default.