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

@unhingged/vizu-react

v0.1.21

Published

React bindings for @unhingged/vizu-core — VizuProvider, useVizu, useComments, useVizuUser, useVizuEvent.

Downloads

2,643

Readme

@vizu/react

React bindings for @vizu/core. Drop a provider in your tree, use hooks to read comments / set identity / register actions.

npm install @vizu/core @vizu/react

Use it

'use client';
import { VizuProvider, useVizu, useComments, useVizuUser, useVizuEvent, useVizuAction } from '@vizu/react';

export default function App() {
  return (
    <VizuProvider options={{
      namespace: 'my-site',
      pageVersion: 'v1',
      shortcut: 'mod+shift+e',
      user: { name: 'Anonymous' },
      startEnabled: true,
    }}>
      <YourPage />
    </VizuProvider>
  );
}

function YourPage() {
  // 1. Read current user (re-renders on setUser)
  const [user, setUser] = useVizuUser();

  // 2. Hydrate identity from your auth/session
  useEffect(() => {
    setUser({ id: session.userId, name: session.name, avatarUrl: session.avatar });
  }, [session]);

  // 3. Read live comments (re-renders on add/remove/clear/set)
  const comments = useComments();

  // 4. Listen to events — persist to your backend
  useVizuEvent('comment:added', ({ comment }) => {
    fetch('/api/comments', { method: 'POST', body: JSON.stringify(comment) });
  });

  // 5. Register a pill action
  useVizuAction({
    id: 'send-to-api',
    label: 'Send to API',
    variant: 'primary',
    onClick: (ctx) => fetch('/api/iterate', {
      method: 'POST',
      body: JSON.stringify({ comments: ctx.comments, pageHtml: ctx.pageHtml }),
    }),
    visibleWhen: ({ commentsCount }) => commentsCount > 0,
  });

  // 6. Imperative access
  const vizu = useVizu();
  useEffect(() => {
    // Pre-load comments from your backend
    fetch(`/api/comments?ns=my-site`).then(r => r.json()).then(c => vizu.setComments(c, { persist: false }));
  }, [vizu]);

  return <div>Your page content…</div>;
}

What you get

  • <VizuProvider> — mounts a single Vizu instance for the subtree (lazy, destroyed on unmount)
  • useVizu() — the instance itself for imperative calls (vizu.enable(), vizu.clearAll(), etc.)
  • useComments() — subscribes to all comment-list events, returns VizuComment[]
  • useVizuUser()[user, setUser] tuple, re-renders on user:changed
  • useVizuEvent('event', handler) — subscribe to any Vizu event for the component lifetime
  • useVizuAction({...}) — register an action while mounted; auto-removed on unmount

Storage defaults

Programmatic mode defaults to in-memory storage. Provide options.storage if you want persistence:

<VizuProvider options={{ storage: 'local' }}>...
<VizuProvider options={{ storage: myCustomAdapter }}>...

Or skip storage entirely and own it in your effects — listen to comment:added and POST to your API.

Next.js (App Router)

VizuProvider is a client component (it uses refs + effects). Put it inside a layout that opts in:

// app/(commentable)/layout.tsx
'use client';
import { VizuProvider } from '@vizu/react';
export default function Layout({ children }) {
  return <VizuProvider options={{ namespace: 'my-app' }}>{children}</VizuProvider>;
}

Page-level usage stays as Server Components; only the provider and the components that call its hooks need the 'use client' directive.