Skip to content

Guides ​

New to the router? Start with What is Lit UI Router?, then the tutorial.

Task-oriented pages for the concepts real apps hit after the tutorial. Each guide is grounded in the sample app's working implementation — a webmail + contacts client deployed across every point on the server-support spectrum.

URLs & Location ​

  • Location Plugins — choosing a URL strategy: hash, pushState, or the Navigation API; server rewrites, the <base> tag, and the initial rule
  • State Parameters — path, query, typed, optional, squash, dynamic, and non-URL parameters, plus custom parameter types
  • Unmatched URLs (404) — route URLs that match no state to a deliberate 404 state with urlService.rules.otherwise

Transitions & Guards ​

  • Route Guards — protect states with transition hooks: the requiresAuth pattern, redirect-to-login, and returning the user after authentication
  • Redirects — static and dynamic redirectTo on states, transition-hook redirects, and urlService.rules (initial, when, otherwise)
  • Loading and Error Views — a pending indicator while a transition runs, skeletons for NOWAIT resolves, and an error view with retry when a transition fails
  • Routed Components — reading a state's params through a resolve, code-splitting a route's element with an awaited import or a lazyLoad future state, and reaching the element a view rendered
  • Named Views — fill several <ui-view name="…"> viewports from one state with views, and target a view another state created with name@state, relative ^ anchors and absolute ! paths
  • View Fallback Content — what a <ui-view> renders when no routed component is active: the capture rules, the list/detail idiom, and what a prerendered shell emits
  • Component Lifecycle Hooks — uiCanExit for unsaved-changes prompts and uiOnParamsChanged for dynamic parameters
  • Links and Navigation — declarative links with uiSref, active classes and aria-current with uiSrefActive, relative targets, attribute-part sref* forms, SrefStatusController, and programmatic navigation with stateService
  • Design System Links — driving a design system's link component (<sp-link>, <md-*>, an in-house one) with uiSref: assignHref: true is the option for a custom element that declares its own href, and 'auto' scopes the attribute to real <a> elements, with a live example contrasting all three cases

Reactivity ​

  • Reactive Components — keep components outside <ui-view> in sync with the router using the zero-dependency TransitionController

Server-side ​

The server-side overview maps the verdict, render and host choices to the pages below.

  • Server-Side Routing — serve routing verdicts at the edge with ui-router-server: the app shell for real routes, 302 entry redirects, and real 404s for everything else, across the full server-support spectrum (every level live on the site), and lit-ui-router-ssr for prerendering those verdicts to static html at build time
  • Prerender with Vite — one serverRouterPlugin option and a prerender script turn vite build into one HTML page per route, a 404.html and a _redirects file, decided by the app's own route table
  • Prerender with Eleventy — Eleventy writes the pages, the layout and the host rules; prerender() decides what each path is and renders it, and the client adopts the served page

Builds & Diagnostics ​

  • Development and Production Builds — the development export condition, the warnings the development build carries and the production build cannot print, and which packages ship two builds at all
  • Linting — catch routing mistakes at author time with eslint-plugin-lit-ui-router, where lint sits beside typed routes and development warnings, and pointers for the rest of your Lit code
  • Tracing Transitions — instrument transitions in production with ui-router-otel and OpenTelemetry: param allowlists and message redaction, active spans across resolves, hooks and lazy loads, and shipping to an OTLP backend or the devtools Timeline

Coming from Another Router ​

  • Coming from UI-Router — side-by-side mapping from @uirouter/angular and @uirouter/react to lit-ui-router, what stays identical in @uirouter/core, and what changes in Lit

Companion Packages ​

The companion packages — Effect, MobX and Signals bindings, the Navigation API location plugin, typed state names, server-side routing verdicts, static prerendering, development tooling, ESLint rules and OpenTelemetry spans — are optional and independently versioned, each with its own guide and API reference.