Skip to content

Sample App ​

The sample app is a webmail + contacts client that puts lit-ui-router's guides together in one running application: nested and named views, protected routes with a login flow, lazy-loaded feature modules, sticky states, unsaved-changes guards, 404 handling, and a live feature-flags panel for switching location plugins.

Authentication is mocked locally — pick any user and enter password to sign in.

What it demonstrates ​

FeatureSource fileGuide
Route guards & login redirectrequiresAuth.hook.ts, Login.tsRoute Guards
Lazy-loaded .** future statesmain/states.tsRouted Components
Named views (mymessages, contacts, messagelist, messagecontent)App.ts, MyMessages.ts, mymessages/states.tsNamed Views
Unsaved-changes guard (uiCanExit)contacts/EditContact.tsComponent Lifecycle Hooks
Sticky states & deep state redirectcontacts/states.ts, mymessages/states.ts@uirouter/sticky-states, @uirouter/dsr
Location plugins & runtime switchingprefs/FeatureFlagsPanel.tsLocation Plugins
Unmatched URLs & server verdictsmain/NotFound.ts, routes.tsUnmatched URLs (404), Server-Side Routing
Typed state namesregistry/states.ts, contacts/states.tsui-router-registry

Devtools and visualizer ​

The sample app includes an in-repo devtools panel showing the state tree and each transition. Append ?feature-enable-visualizer=true to any mount's URL to also load @uirouter/visualizer (add &feature-enable-devtools=false to run the visualizer on its own).

API viewer ​

Append ?feature-enable-api-docs=true to show an API viewer below the app. It reads lit-ui-router/custom-elements.json and lists the properties, attributes and events of the elements lit-ui-router defines. It is off by default.

Live mounts ​

The same routing table is deployed in four client-state variants (all behind the same route-aware edge worker) plus a hash-location build:

MountSpectrum levelClient state & routing
/app3+4Vanilla (TransitionController) — flagship route-aware server (shell for real routes, computed 302s, real 404s).
/app-mobx3+4MobX — identical routes and server verdicts, with client state in MobX stores.
/app-effect3+4Effect — identical routes and server verdicts, with client state in SubscriptionRefs.
/app-signals3+4Signals — identical routes and server verdicts, with client state in TC39 Signals via @lit-labs/signals.
/app-hash1Hash location — the route lives in the fragment, so the server serves the shell at 200 at the mount root and needs no routing verdicts.

Server-semantics exhibits ​

Three additional noindex mounts deploy the same app behind different server configurations so you can compare each point on the server-support spectrum side by side:

MountSpectrum levelWhat it shows
/not-found-naive2The anti-pattern baseline: every path answers 200 with the shell, no matching at all — the soft-404 fallback most SPAs ship. noindex.
/not-found-spa4Shell-at-404: real routes serve the shell at 200; only a genuine miss serves the app shell at an honest 404, where the client renders its in-app 404 view. noindex.
/simulated-routing5Every verdict computed by a real headless @uirouter/core router replaying the URL per request — redirects and otherwise() run as real rules. noindex.

Two axes, one app ​

Across the routing axis — /app, /app-hash, and the three exhibits above — the mounts differ only in the HTTP verdict a URL earns (the four /app* variants share the same route table and verdicts, varying only client-state bindings). The Server-Side Routing guide is the deep dive on that routing axis.

How the page body is rendered is a separate choice: it does not change which status or redirect a URL gets. Today the sample app mounts are client-rendered throughout; build-time prerendering (Prerender with Vite, Prerender with Eleventy) and request-time server rendering (Rendering one page per request) live in lit-ui-router-ssr.

Source ​

The repository's lint runs the eslint-plugin-lit-ui-router rules over every app. Compare the four client-state entry points side by side against the shared routing and UI layers: