npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

lit-navigation-router

v0.3.0

Published

A router for Lit built on the Navigation API. Fork of @lit-labs/router.

Readme

lit-navigation-router

A router for Lit, built on the Navigation API.

Fork of @lit-labs/router — see NOTICE.md for provenance, licence and the full list of changes. Not affiliated with or endorsed by Google or the Lit team.

npm i lit-navigation-router

Why

Upstream commits navigation with history.pushState() and reacts to popstate, but swaps the outlet only after awaiting route.enter(). The URL therefore leads and the outlet lags, so the route being left re-renders with stale params and two quick navigations can commit out of order.

navigateEvent.intercept() removes that: the browser commits the URL and holds the navigation un-finished while the handler runs, and aborts navigateEvent.signal when a newer navigation supersedes this one.

Usage

Identical to upstream:

import {Router} from 'lit-navigation-router/router.js';

class MyApp extends LitElement {
  private _router = new Router(this, [
    {path: '/', render: () => html`<h1>Home</h1>`},
    {
      path: '/item/:id',
      enter: async () => {
        await import('./item-view.js'); // awaited before the outlet swaps
        return true;
      },
      render: ({id}) => html`<item-view .id=${id}></item-view>`,
    },
  ]);

  render() {
    return html`${this._router.outlet()}`;
  }
}

Two additions:

// Forwarded to navigateEvent.intercept()
this._router.interceptOptions = {scroll: 'manual', focusReset: 'manual'};

// goto() takes an abort signal; Router passes navigateEvent.signal for you
await routes.goto('/item/1', {signal});

Browser support — please read

This router requires the Navigation API. There is no legacy fallback.

The API is Baseline Newly Available (January 2026: Chrome/Edge, Safari 26.2, Firefox 147). Baseline Widely Available is not until roughly mid-2028, so older engines are still in the wild.

On an engine without it, Router renders the current route on load but does not intercept navigation — every link becomes an ordinary full page load. If your server serves the app shell on every route that is slower, not broken. If it does not, those links 404.

One case is genuinely broken, not just slow. If you navigate programmatically with history.pushState() + router.goto(), nothing listens for the resulting popstate — so Back moves the URL while the outlet stays put, which is the URL/outlet split this fork exists to eliminate. Apps using that pattern should gate on supportsNavigationApi() rather than accept the degradation.

supportsNavigationApi() is exported so you can detect this at boot:

import {supportsNavigationApi} from 'lit-navigation-router/router.js';

if (!supportsNavigationApi()) {
  showUpgradePrompt();
}

If you need real pre-2026 support, pair this with a Navigation API polyfill rather than a second router: one decision path, with compatibility isolated in a layer whose whole job is spec accuracy.

URLPattern

Route patterns are compiled with URLPattern, which this package uses from the global scope and does not polyfill — same as upstream. Every engine that has the Navigation API also has URLPattern, so if the support check above passes you need nothing. If you support older engines anyway, load urlpattern-polyfill before the router:

import {URLPattern} from 'urlpattern-polyfill';
if (!globalThis.URLPattern) {
  (globalThis as {URLPattern?: unknown}).URLPattern = URLPattern;
}

The published types do not depend on it — URLPatternRouteConfig.pattern is typed structurally, so a consumer build never needs the polyfill's types.

Develop

npm install
npm run build        # tsc → development/
npm test             # Web Test Runner (Chromium via Playwright)
npm run check-types