Examples · Navigation & server HTML

Router with loaders

Routes as data: a loader fetches before the page swaps, pending is a signal.

A route is an object: loader runs while the old page is still visible, the handler renders with the data, r.pending drives an indicator. Hash mode needs no server rewrite rules, which is why this example uses it.

Playground

What to notice

  • Click User 3, then User 7: the old page stays until the new data arrives.
  • The active link gets aria-current="page" and the on class.
  • A route that does not match falls to *; unknown non-hash paths go to the server.

Set window.__server.latency = 1500 and watch the pending indicator.