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

@routier/react

v0.2.0

Published

React integration examples for Routier framework

Readme

@routier/react

Lightweight React bindings for Routier collections. This package exports the useQuery hook to subscribe to live query results with a simple callback interface.

Install

npm install @routier/react
# peer deps (provided by your app)
npm install react react-dom

Ensure your bundler/app resolves a single copy of React. This package declares React as a peer dependency and does not bundle it.

Exports

import { useQuery } from "@routier/react";

useQuery

Signature:

function useQuery<T>(
  subscribe: (callback: (result: ResultType<T>) => void) => void | (() => void),
  deps?: any[]
): {
  status: "pending" | "success" | "error";
  loading: boolean;
  error: Error | null;
  data: T | undefined;
};

Behavior:

  • Subscribes to your data source and updates when the callback fires.
  • Returns a simple state object: { status, loading, error, data }.
  • Unsubscribes automatically on unmount or dep changes if you return a cleanup function from subscribe.

Examples

Count example:

const productCount = useQuery<number>(
  (cb) => dataStore.products.subscribe().count(cb),
  []
);

if (productCount.status === "success") {
  console.log(productCount.data);
}

Array example:

const products = useQuery<any[]>(
  (cb) => dataStore.products.subscribe().toArray(cb),
  []
);

if (products.status === "success") {
  products.data?.forEach((p) => console.log(p.name));
}

Custom subscription with cleanup:

useQuery(
  (cb) => {
    const sub = dataStore.products.subscribe();
    const unsubscribe = sub.onChange(() => sub.toArray(cb));
    // initial emit
    sub.toArray(cb);
    return unsubscribe;
  },
  [
    /* deps */
  ]
);

Troubleshooting: Invalid hook call

If you see "Invalid hook call":

  1. Ensure a single React instance in your app (npm ls react).
  2. Do not import internal source files; import from @routier/react.
  3. Your bundler should alias react and react-dom to the app’s node_modules (monorepo setups):
// webpack/rspack
resolve: {
  alias: {
    react: path.resolve(__dirname, 'node_modules/react'),
    'react-dom': path.resolve(__dirname, 'node_modules/react-dom')
  }
}

Notes

  • React is a peer dependency (not bundled).
  • The library builds to ESM and CJS and ships TypeScript declarations.