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

@everystate/router

v1.0.2

Published

EveryState Router: SPA router for EveryState stores. Routing is just state

Downloads

172

Readme

@everystate/router

SPA router for EveryState: routing is just state.

Treat routing as state. Routes, params, query strings, and navigation history live in your EveryState store at ui.route.*.

Installation

npm install @everystate/router @everystate/core

Quick Start

import { createEveryState } from '@everystate/core';
import { createRouter } from '@everystate/router';

const store = createEveryState({});

const router = createRouter({
  store,
  routes: [
    { path: '/',           view: 'home',  component: HomeView },
    { path: '/about',      view: 'about', component: AboutView },
    { path: '/users/:id',  view: 'user',  component: UserView },
  ],
  fallback: { view: '404', component: NotFoundView },
}).start();

// Subscribe to route changes
store.subscribe('ui.route.view', (view) => {
  console.log('View changed:', view);
});

// Navigate programmatically
router.navigate('/users/123');

// Or navigate from anywhere via the store (no router import needed)
store.set('ui.route.go', '/about');
store.set('ui.route.go', { path: '/users/1', search: '?tab=posts' });
store.set('ui.route.go', { query: { tab: 'posts' } }); // patch query only

// Access route state
store.get('ui.route.view');   // 'user'
store.get('ui.route.path');   // '/users/123'
store.get('ui.route.params'); // { id: '123' }
store.get('ui.route.query');  // { tab: 'posts' }

Route Config

createRouter({
  store,                                      // EveryState store instance
  routes: [{ path, view, component }],        // route definitions
  fallback: { view, component },              // 404 fallback (optional)
  rootSelector: '[data-route-root]',          // mount point (default)
  linkSelector: 'a[data-link]',              // intercepted links (default)
  navSelector: 'nav a[data-link]',           // auto .active class (default)
  debug: false,                               // console.debug logging
});

Component Boot Protocol

Each route's component must expose a boot() function:

export const HomeView = {
  async boot({ store, el, signal, params }) {
    el.innerHTML = '<h1>Home</h1>';
    // Return an unboot function for cleanup
    return () => { el.innerHTML = ''; };
  }
};

Features

  • Routes as state - current route at ui.route.view, ui.route.path
  • Params as state - URL params at ui.route.params.*
  • Query as state - query string at ui.route.query.*
  • Store-driven navigation - store.set('ui.route.go', '/path') from anywhere
  • Transition state - ui.route.transitioning flag for loading indicators
  • History integration - browser back/forward with scroll position restore
  • Base path support - auto-detects <base href> for subdirectory deploys
  • Nav active state - auto-toggles .active class on nav a[data-link] elements
  • Abort controller - cancels in-flight boots when navigation is superseded
  • Focus management - moves focus to route root for accessibility
  • Framework-agnostic - works with any view layer or vanilla DOM

API

| Method | Description | |---|---| | router.start() | Begin listening for clicks and popstate events | | router.stop() | Remove all listeners and clean up | | router.navigate(path, opts?) | Navigate to a path ({ replace, search, restoreScroll }) | | router.navigateQuery(patch, opts?) | Patch query params without changing path | | router.navigatePath(path, opts?) | Navigate keeping current search string | | router.getCurrent() | Returns { view, path, search } |

License

MIT © Ajdin Imsirovic