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

@farbenmeer/router

v0.5.0

Published

A lightweight, React-based client-side router with support for nested routes, path parameters, and immutable search parameter handling.

Readme

@farbenmeer/router Documentation

A lightweight, React-based client-side router with support for nested routes, path parameters, and immutable search parameter handling.

Overview

The @farbenmeer/router package provides a very lightweight routing solution for React applications with the following key features:

  • Declarative routing with React components
  • Nested routes with parameter inheritance
  • Path parameters with colon syntax (:id)
  • Wildcard routes for catch-all paths (* and *name)
  • Immutable search parameters for predictable state management
  • Client-side navigation with history management
  • TypeScript support for better development experience
  • Testing-friendly with customizable location and history

Quick Start

import { Router, Route, Link } from "@farbenmeer/router";

function App() {
  return (
    <Router>
      <nav>
        <Link href="/">Home</Link>
        <Link href="/users">Users</Link>
        <Link href="/about">About</Link>
      </nav>

      <main>
        <Route path="/">
          <HomePage />
        </Route>

        <Route path="/users">
          <UsersLayout />
          <Route exact>
            <UsersList />
          </Route>
          <Route path=":id">
            <UserProfile />
          </Route>
        </Route>

        <Route path="/about">
          <AboutPage />
        </Route>
      </main>
    </Router>
  );
}

Components

Router

The root component that provides routing context to your application.

  • Manages current location state
  • Provides navigation methods
  • Supports custom location and history for testing
  • Normalizes pathnames (removes trailing slashes)

Route

Conditionally renders content based on the current pathname.

  • Path matching with parameters (/users/:id)
  • Wildcard matching (/files/* or /files/*path)
  • Exact matching option
  • Nested route support
  • Parameter inheritance from parent routes

Link

Declarative navigation component that renders as an anchor element.

  • Client-side navigation with history management
  • Supports absolute and relative paths
  • Query parameter handling

Hooks

useRouter

Provides programmatic navigation methods.

const router = useRouter();
router.push("/users/123");     // Navigate with history
router.replace("/login");      // Replace current entry

usePathname

Access the current pathname for conditional rendering and active states.

const pathname = usePathname();
const isActive = pathname === "/users";

useSearchParams

Access and manipulate URL search parameters with immutable methods.

const searchParams = useSearchParams();
const query = searchParams.get("q");
const newParams = searchParams.set("filter", "active");

useParams

Extract parameters from dynamic route segments.

// Route: /users/:id/posts/:postId
const params = useParams(); // { id: "123", postId: "456" }

useHash

Access the current URL hash fragment for tab navigation and anchor linking.

const hash = useHash();
const activeTab = hash.slice(1) || "overview";

Key Features

Nested Routing

Create hierarchical route structures with parameter inheritance:

<Route path="/organizations/:orgId">
  <OrganizationLayout />

  <Route path="teams/:teamId">
    <TeamLayout />

    <Route path="members/:memberId">
      <MemberProfile />
    </Route>
  </Route>
</Route>

Path Parameters

Define dynamic segments with colon syntax:

<Route path="/users/:id">          {/* /users/123 */}
<Route path="/posts/:slug">        {/* /posts/hello-world */}
<Route path="/api/:version">       {/* /api/v1 */}

Wildcard Routes

Match arbitrary paths with wildcards:

<Route path="/files/*">            {/* Matches /files/a, /files/a/b/c, etc. */}
<Route path="/docs/*path">         {/* Matches and captures as params.path */}
<Route path="/api/:version/*rest"> {/* Combines params with wildcards */}

The * wildcard matches everything including slashes, making it perfect for catch-all routes. Use *name to capture the matched path as a parameter accessible via useParams().

Immutable Search Parameters

Safely update URL search parameters without mutations:

const searchParams = useSearchParams();
const withFilter = searchParams.set("category", "electronics");
const withSort = withFilter.set("sort", "price");

Testing Support

Provide custom location and history for predictable tests:

<Router
  location={{ pathname: "/users/123", search: "?tab=profile", hash: "#bio" }}
  history={mockHistory}
>
  <App />
</Router>

Common Patterns

Active Navigation Links

function NavLink({ href, children }) {
  const pathname = usePathname();
  const isActive = pathname === href;

  return (
    <Link
      href={href}
      className={isActive ? 'nav-link active' : 'nav-link'}
    >
      {children}
    </Link>
  );
}

Search and Filtering

function ProductSearch() {
  const router = useRouter();
  const pathname = usePathname();
  const searchParams = useSearchParams();

  const updateFilter = (key: string, value: string) => {
    const newParams = searchParams.set(key, value);
    router.push(`${pathname}?${newParams.toString()}`);
  };

  return (
    <select onChange={(e) => updateFilter("category", e.target.value)}>
      <option value="">All Categories</option>
      <option value="electronics">Electronics</option>
    </select>
  );
}

API Reference

For detailed API documentation, see the individual component and hook documentation files linked above.