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

@ganeshdole/brainbox-react

v0.3.0

Published

React bindings for @ganeshdole/brainbox-core: a provider that owns one Brainbox instance and hooks that read it. No UI.

Readme

@ganeshdole/brainbox-react

React bindings for @ganeshdole/brainbox-core: a provider that owns one instance, and hooks that read it. The react-redux to core's redux. No UI lives here; for Brainbox's own widget see @ganeshdole/brainbox-widget.

Install

Inside this monorepo the package is consumed from source. react (19+) is a peer dependency, so a host ends up with one copy.

{ "dependencies": { "@ganeshdole/brainbox-react": "workspace:*" } }

Outside it, from npm:

npm install @ganeshdole/brainbox-react @ganeshdole/brainbox-core

pnpm build emits dist/ (JS plus .d.ts); the published package's exports point at it (publishConfig).

Use

import { BrainboxProvider, useBrainbox, useDraft } from "@ganeshdole/brainbox-react";
import { brainboxTransport } from "@ganeshdole/brainbox-core";

// Keep the transport stable: a new one means a new instance.
const transport = brainboxTransport({ endpoint, projectKey });

export function Root() {
  return (
    <BrainboxProvider
      transport={transport}
      identity={{ id: user.id, email: user.email, name: user.name, phone: user.phone }}
      fields={[
        { label: "Plan", value: account.plan, highlight: true },
        { label: "Account ID", value: account.id, type: "id" },
      ]}
    >
      <App />
    </BrainboxProvider>
  );
}

identity is who is reporting, and fields are your app's own details, whatever you want next to every report. The dashboard shows both in the report's "Reported by" card: the person's name, email and phone, then your fields with your labels, in your order. Adding one needs no change in Brainbox. type is optional: email, phone and url become links, id shows in monospace, anything else is text. highlight: true also puts a field's value under the person's name, for the one or two details that say where a report came from. Up to 30 fields, labels up to 60 characters, values up to 500.

Your own UI on top of the engine:

function FeedbackPanel() {
  const brainbox = useBrainbox();           // null on the server and the first render
  const panel = useRef<HTMLDivElement>(null);
  const draft = useMemo(() => brainbox?.draft({ exclude: panel.current ?? undefined }), [brainbox]);
  if (!draft) return null;
  return <Panel ref={panel} draft={draft} />;
}

function Panel({ draft }: { draft: Draft }) {
  const state = useDraft(draft);            // re-renders on every change
  return state.screenshotPending ? <Spinner /> : <img src={state.screenshotUrl ?? ""} />;
}

How the provider behaves

  • The instance is created in an effect and destroyed in the cleanup. That keeps a server render side-effect free and leaves exactly one instance under StrictMode's mount-unmount-mount. The cost is one render in which useBrainbox() is null.
  • identity changes call identify(), and fields changes call setFields(), on the live instance. The fields prop owns the instance's fields: dropping it clears them. onSubmitted may change freely. Only a new transport rebuilds the instance.
  • <BrainboxProvider brainbox={instance}> provides an instance you created and own. Shells outside React (the script-tag bundle) use this.