Skip to content
nav-router

Examples / Start

Your first router

A layout, two named routes and a param. Every link is built from a route name, not a pasted path.

Try this

  1. Click Ada, then Mo. The URL bar follows: /people/ada, then /people/mo.
  2. Press back in the preview’s bar. Ada’s page comes back from history.
  3. Rename someone in PEOPLE in routes.js. The preview rebuilds and stays on the same page.
app/

Starting…

How it works

routes is the whole app: the root route holds the layout, index is the page at /, and member takes a :userId param. The layout writes a <slot> where the page goes, and href() builds each link from a route name and its params.

The links are plain anchors. The router catches the browser’s own navigate event, so there is no link component and nothing to wire up per link.