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

literaljs-router

v1.0.0

Published

A tiny client-side router for LiteralJS v8+. Returns VNodes, supports named parameters, and works with the App class API.

Readme

LiteralJS Router v1.0.0

A tiny client-side router for LiteralJS v8+.

  • Returns VNodes — works directly with LiteralJS h() and the v8 renderer
  • Named parameters/users/:id extracts { id: '123' }
  • Programmatic navigationnavigate('/about') with pushState
  • App class API — triggers re-render via CustomEvent, no set() callback needed
  • Zero extra dependencies — only needs literaljs as a peer dep
  • ~600 bytes gzipped

Install

npm install literaljs-router

Usage

/** @jsx h */
import { h, component, App } from 'literaljs';
import { Router, navigate } from 'literaljs-router';

// Define page components
const Home = component({
  name: 'Home',
  render() {
    return (
      <div>
        <h1>Welcome Home</h1>
        <button events={{ click: () => navigate('/docs') }}>
          Go to Docs
        </button>
      </div>
    );
  }
});

const Docs = component({
  name: 'Docs',
  render() {
    return <div><h1>Documentation</h1></div>;
  }
});

// Define routes
const routes = [
  { path: '/', render: () => h(Home) },
  { path: '/docs', render: () => h(Docs) },
  { path: '/404', render: () => h('div', {}, 'Not Found') }
];

// Root component uses Router
const App = component({
  name: 'App',
  render() {
    return (
      <div>
        <nav>...</nav>
        <Router routes={routes} />
      </div>
    );
  }
});

new App(App, {}).mount('root');

Named Parameters

const routes = [
  { path: '/users/:id', render: ({ params }) => h(UserPage, { userId: params.id }) },
];

// navigate('/users/42') → params = { id: '42' }

API

Router({ routes, key? })

The main router component. Place it in your root component's render method.

  • routes — Array of { path: string, render: (ctx) => VNode } objects
  • key — Store key for current path (default: 'location')

The render function receives { params, path } as its argument.

navigate(path)

Programmatically navigate to a path. Uses history.pushState and dispatches a popstate event.

import { navigate } from 'literaljs-router';
navigate('/about');

getParams()

Parse query string parameters from the current URL.

import { getParams } from 'literaljs-router';
// On /search?q=hello&page=2
const params = getParams(); // { q: 'hello', page: '2' }

getPathParams(pattern, path)

Extract named parameters from a matched route pattern.

Changes from v0.x

  • Returns VNodes (h() calls) instead of plain objects
  • Named route parameters (:id, :slug, etc.)
  • navigate() for programmatic navigation
  • CustomEvent-based re-render trigger (compatible with App class)
  • No mutable set() callback — works with v8.0.4 App API
  • Smaller footprint

License

MIT