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

@cajuncodemonkey/naics-search-react

v1.0.0

Published

React hook wrapping @cajuncodemonkey/naics-search's async load-state.

Readme

@cajuncodemonkey/naics-search-react

A thin React hook wrapping @cajuncodemonkey/naics-search's async load-state, so a React app doesn't have to hand-roll "is the model loaded yet, did it error" boilerplate around loadNaics().

Built for naics-code-resolver — see that repo for the full resolver UI this package's sibling naics-search powers.

Install

npm install @cajuncodemonkey/naics-search-react @cajuncodemonkey/naics-search

react (^19) is a peer dependency — bring your own, this package doesn't bundle it.

Usage

import { useNaicsSearch } from "@cajuncodemonkey/naics-search-react";

function Resolver() {
  const naics = useNaicsSearch();

  if (naics.status === "loading") return <p>Loading…</p>;
  if (naics.status === "error") return <p>Couldn't load NAICS data: {String(naics.error)}</p>;

  // naics.status === "ready" — search()/drilldown fns are available
  return <SearchForm onSubmit={(text) => naics.search(text)} />;
}

API

useNaicsSearch(): Status

No arguments — data-source configuration (if you need it) is set globally via naics-search's configureDataProvider() before your app mounts, not through this hook. Status is a discriminated union on status:

type Status =
  | { status: "loading" }
  | { status: "error"; error: unknown }
  | {
      status: "ready";
      search: typeof search;
      drilldownOptions: typeof drilldownOptions;
      getNode: typeof getNode;
      isResolved: typeof isResolved;
      getAncestorPath: typeof getAncestorPath;
      censusUrl: typeof censusUrl;
    };

TypeScript narrows naics.search/the drilldown fns into scope only once naics.status === "ready" — there's no runtime guard to remember, the type system enforces it.

The hook owns no app policy — confidence bands, settings, Q&A UI flow all stay in your app, same as they do in naics-code-resolver's own app.

Caveats

  • Unmounting mid-load is safe — the hook guards against setState on an unmounted component. It does not cancel the underlying loadNaics() fetch (that's a shared, cached load across the whole app, not owned by any one hook instance).
  • No built-in retry UI. naics-search's cache only holds onto a successful load, not a failed one, so remounting the component that calls useNaicsSearch() (e.g. a React key change) after an error retries fresh. The hook itself has no manual retry() — it's a one-shot-per-mount wrapper by design.

License

MIT.