#router objects

Within a Navi app, the Router class is tasked with matching URLs to Route objects, and is also able to produce a SiteMap that maps all possible URLs to their corresponding Route objects.

To access a router object, you can use the navigation.router property of your navigation store. Or to use a router when declaring your routes, you can access the Env object’s env.router property.


router.resolve(url, options?: {
  followRedirects?: boolean,
  withContent?: boolean,

Returns a Promise<Route>


router.resolveSiteMap(url, options? :{
  followRedirects?: boolean,
  maxDepth?: number,
  predicate?: (segment: Segment) => boolean,

Returns a Promise<SiteMap> that maps each of the URLs under and including url to a Route object.

This is useful for automatically generating lists of content, e.g. for a blog’s index page, a static rendering tool, or a sidebar. In fact, this site’s navigation sidebars are all generated using the result of router.resolveSiteMap().