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

@arachnejs/router

v0.4.1

Published

Signal-driven client router for Arachne

Downloads

1,136

Readme

@arachnejs/router

Signal-driven router for Arachne: nested layouts, code-split (lazy) routes, per-route data, head/title management, <Link> and link interception, base paths, scroll handling. Runs in the browser, on the server (SSR) and at build time (static prerendering) with the same route table. The path compiler is shared with @arachnejs/server (@arachnejs/router/path). See ADR 0009.

import { browserHistory, createRouter, Link } from "@arachnejs/router";

const routes = [
  {
    path: "/",
    component: (p) => <div class="site"><Nav />{p.children}</div>, // layout
    head: { title: "Home" },
    children: [
      { path: "", component: Home },                                  // index page
      { path: "blog", lazy: () => import("./Blog.tsx") },             // code-split
      {
        path: "blog/:slug",
        component: (p) => <Post post={p.data as Post} />,
        head: ({ data }) => ({ title: (data as Post).title }),
      },
    ],
  },
];

const router = createRouter({
  routes,
  history: browserHistory(),
  base: "/docs",                    // app mounted at site.com/docs
  titleTemplate: "%s · My site",
  load: (match) => fetch(`/data${match.pathname}.json`).then((r) => r.json()), // per-route data
  initialData: window.__DATA__,     // from server-rendered HTML
  fallback: NotFound,
  error: ErrorPage,
});
router.interceptLinks();            // plain <a href="/…"> inside the page route client-side

render(() => <>{router.Outlet()}</>, document.getElementById("app")!);
  • Layouts: a route with children renders its component around the matched child (props.children); path: "" is the index child. A layout stays mounted while you navigate between its children (its DOM, scroll positions and local state survive); its params/location/data props update in place. Pages are re-created on every navigation.
  • Lazy routes: lazy: () => import("./Page.tsx") (default export or the component) loads before the route commits; router.preload(path) warms it.
  • Data: load(match) runs for every navigation; the URL and view switch together when it resolves, router.pending() is true meanwhile, and stale navigations are dropped. Errors render error with props.error.
  • Head: static or ({ params, data, location }) => ({ title, meta, links, lang }), merged outer → inner, applied to document on navigation; renderHead(router.head()) produces the server HTML. lang sets <html lang> for that page (a bilingual site: /ru/* routes say lang: "ru"); the kit renders it, and applyHead keeps it in step on navigation.
  • Links: <Link href="/blog"> renders a real <a> (base path applied, aria-current="page" + activeClass when active, prefetch on hover/focus). shouldIntercept skips modified clicks, target, download, rel="external", other origins and unknown paths.
  • Scroll: top on push, hash target when present, restored on back/forward (scroll: false to opt out).
  • router.Outlet() in a JSX expression is reactive; <router.View /> is the component form.

| API | Description | |---|---| | createRouter(options) | routes, history, load, initialData, base, titleTemplate, fallback, error, scroll | | router.navigate(to, { replace }) | resolves after the route renders | | router.location() / params() / matched() / data() / pending() / error() / head() | signals | | router.ready | initial route loaded (SSR: await before rendering) | | router.href(path) · resolve(path) · preload(path) · interceptLinks(root?) · back() · dispose() | | | memoryHistory(url) · browserHistory() | history sources | | compilePath(pattern) · parseLocation(url) | path utilities (also @arachnejs/router/path) | | mergeHeads · renderHead · applyHead | head utilities |