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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@webstd-ui/router

v0.2.0

Published

A framework-agnostic client-side router built on @remix-run/fetch-router and @remix-run/events

Readme

@webstd-ui/router

A framework-agnostic client-side router built on @remix-run/fetch-router and @remix-run/events. This package provides a generic routing solution that works with any rendering library or framework.

Features

  • Framework Agnostic: Works with any UI library (Remix, Preact, Solid, Lit, vanilla JS, etc.)
  • Type-Safe: Full TypeScript support with comprehensive type definitions
  • Event-Driven: Built on @remix-run/events for reactive updates
  • Navigation States: Track loading, submitting, and idle states
  • Form Handling: Automatic interception of <form> submissions
  • Link Interception: Handles <a> clicks for seamless SPA navigation
  • Optimistic UI: Built-in support for optimistic updates
  • Redirects: Server-style redirects with Response objects
  • History Management: Integrated with browser History API for Safari and Firefox compatibility

Installation

pnpm add @webstd-ui/router

Basic Usage

import { Router } from "@webstd-ui/router";
import { route } from "@remix-run/fetch-router";
import { events } from "@remix-run/events";

// Create a router instance
const router = new Router();

// Define routes
const routes = route({
  home: "/",
  about: "/about",
  contact: { method: "POST", pattern: "/contact" },
});

// Map routes to handlers
router.map(routes, {
  async home() {
    return `<h1>Home Page</h1>`;
  },
  async about() {
    return `<h1>About Page</h1>`;
  },
  async contact({ formData }) {
    // Handle form submission
    const name = formData.get('name') as string;
    return `<p>Thanks, ${name}!</p>`;
  },
});

// Listen for updates
events(router, Router.update(() => {
  // Re-render your UI
  render(router.outlet);
}));

// Programmatic navigation
await router.navigate("/about");

API Reference

Router Class

Properties

  • location: Current browser location after successful navigation
  • navigating: Navigation state object with to and from information
  • outlet: The rendered content from the matched route handler
  • storage: Per-request storage shared across route handlers

Methods

  • map(routes, handlers): Register routes and their handlers
  • navigate(to, options): Programmatically navigate to a path
  • submit(target, options): Submit form data to a route
  • isActive(path, exact): Check if a path is currently active
  • isPending(path, exact): Check if a path is pending navigation
  • optimistic(handler, options): Wrap a handler with optimistic UI support

Events

  • Router.update: Fires whenever router state changes (navigation, loading, etc.)

Route Handlers

Route handlers receive a context object with:

// GET requests
{
  params: Record<string, string>,
  method: 'GET',
  url: URL,
  storage: AppStorage
}

// POST/PUT/DELETE requests
{
  params: Record<string, string>,
  method: FormMethod,
  formData: FormData,
  url: URL,
  storage: AppStorage
}

Handlers can return:

  • Renderable content (HTML string, JSX, VNode, etc.)
  • Response object with redirects or JSON
  • null for no content

Examples

See the examples directory for complete applications:

  • Contacts - Contact management with CRUD operations
  • Blog - Blog application
  • Tasks - Task management with async operations

Development

To start the development server:

  1. Install Mise
  2. Run:
mise install
mise run :dev

License

MIT