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

@phcdevworks/spectre-shell-router

v1.0.0

Published

Minimal, framework-agnostic client-side router for Spectre-based applications.

Downloads

316

Readme

@phcdevworks/spectre-shell-router

GitHub issues GitHub pull requests License

@phcdevworks/spectre-shell-router is a minimal, framework-agnostic client-side router for Spectre-based applications.

Maintained by PHCDevworks as part of the Spectre platform, it handles URL matching, navigation, route params, query parsing, and browser history integration. It provides resolved route state to consuming shell logic while remaining responsible only for routing. It does not own sensory behavior, signals, rendering, or application orchestration.

Contributing | Changelog | Security Policy

Key capabilities

  • URL and path matching for client-side routes
  • Route parameter extraction from path patterns
  • Query string parsing via standard browser APIs
  • Programmatic navigation through router helpers
  • Browser history integration using the native History API
  • Resolved route state for consuming shell logic
  • Lightweight, framework-agnostic routing contract

Installation

npm install @phcdevworks/spectre-shell-router

Quick start

Define a route table, create the router, and let route modules receive resolved route state through the routing contract. The router resolves the URL and hands the matched context to your module; how that module updates the DOM stays outside the router's responsibility.

import { Router, type Route, type RouteContext } from '@phcdevworks/spectre-shell-router'

const routes: Route[] = [
  {
    path: '/',
    loader: async () => import('./pages/home'),
  },
  {
    path: '/users/:id',
    loader: async () => import('./pages/user-detail'),
  },
]

const root = document.getElementById('app')

if (!root) {
  throw new Error('Missing application root element')
}

const router = new Router(routes, root)

router.navigate('/users/42?tab=profile')

// pages/user-detail.ts
export function render(ctx: RouteContext) {
  const userId = ctx.params.id
  const tab = ctx.query.get('tab')

  ctx.root.textContent = `User ${userId} (${tab ?? 'overview'})`
}

export function destroy() {
  // Optional cleanup before the next route renders.
}

Depending on how your shell is structured, consuming logic can use the resolved route context passed to render(ctx) as current routing state.

What this package owns

  • Client-side routing behavior
  • Route matching and resolution
  • Path params and query extraction
  • Navigation and history coordination
  • Stable routing contract for shell consumers

What this package does not own

  • Rendering or view components
  • Framework adapters for UI delivery
  • Signals or application state systems
  • Data fetching
  • Application business logic
  • Shell orchestration outside routing concerns

Package exports / API surface

The root package exposes a small routing surface intended to stay easy to understand and easy to replace.

  • Route definitions
  • Router instance for navigation and history coordination
  • Route context and page module types
  • URL matching, params extraction, and query access

In the current package shape, that surface includes the router class and core TypeScript types used to describe routes, page modules, and route context.

Package boundary

@phcdevworks/spectre-shell-router stays intentionally narrow:

  • it resolves URLs into route modules
  • it extracts params and query values
  • it coordinates navigation through the browser History API
  • it passes resolved routing context into the matched module

Rendering, state management, data loading, styling, animation, and shell orchestration stay outside this package.

Development

Install dependencies, then run the package checks:

npm run build
npm test

Key source areas:

  • src/ for router implementation and package exports
  • tests/ for routing and navigation coverage

Contributing

PHCDevworks maintains this package as part of the Spectre suite.

When contributing:

  • keep the routing surface minimal
  • preserve framework-agnostic behavior
  • keep responsibility boundaries explicit
  • run npm run build and npm test before opening a pull request

See CONTRIBUTING.md for the full workflow.

License

MIT © PHCDevworks. See LICENSE.