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

@emito/react-hooks

v0.1.0

Published

Headless React hooks for Emito in-app notifications — EmitoProvider, useNotifications, useUnreadCount, usePreferences, useToast.

Readme

@emito/react-hooks

React hooks for the Emito notification client.

License Types

React TypeScript

What it is

@emito/react-hooks is a thin, headless React layer over @emito/js, the browser notification client. It wraps a single EmitoClient instance in a React context and exposes hooks for the in-app inbox: listing notifications, tracking the unread count, managing subscriber preferences, and surfacing real-time toasts. The hooks keep their state in sync with the client's live WebSocket events, applying optimistic updates for read/archive/snooze actions.

The package ships no UI. It manages client lifecycle and state so you can render notifications however your application needs.

Install

Emito is developed as a pnpm workspace; the @emito/* packages are consumed from within the monorepo. Add the hooks (and the browser client) to a workspace package as workspace dependencies:

// package.json
"dependencies": {
  "@emito/react-hooks": "workspace:*",
  "@emito/js": "workspace:*"
}

Standalone npm publishing of the @emito/* scope is planned but not yet available — install from the workspace for now.

react (>=18) is a peer dependency and is expected to already be present in your application.

Usage

Wrap your tree in EmitoProvider once, then call the hooks anywhere beneath it.

import {
  EmitoProvider,
  useNotifications,
  useUnreadCount,
} from "@emito/react-hooks";

function App() {
  return (
    <EmitoProvider
      endpoint="https://notifications.example.com"
      subscriberId="user_123"
      token="<subscriber-token>"
    >
      <Inbox />
    </EmitoProvider>
  );
}

function Inbox() {
  const { unreadCount } = useUnreadCount();
  const { notifications, isLoading, hasMore, fetchMore, markAsRead } =
    useNotifications({ limit: 20 });

  if (isLoading) return <p>Loading…</p>;

  return (
    <div>
      <h2>Inbox ({unreadCount} unread)</h2>
      <ul>
        {notifications.map((n) => (
          <li key={n.id} onClick={() => markAsRead(n.id)}>
            {n.subject ?? n.body}
          </li>
        ))}
      </ul>
      {hasMore && <button onClick={fetchMore}>Load more</button>}
    </div>
  );
}

EmitoProvider accepts the same options as EmitoClient (endpoint, subscriberId, token, and any other EmitoClientOptions). It connects on mount, disconnects on unmount, and recreates the client when endpoint, subscriberId, or token change.

API surface

The package has a single entry point (@emito/react-hooks).

| Export | Kind | Description | | --- | --- | --- | | EmitoProvider | Component | Context provider that creates and manages an EmitoClient. Accepts EmitoProviderProps (all EmitoClientOptions plus children). | | useEmitoClient | Hook | Returns the raw EmitoClient from the nearest provider. Throws if used outside an EmitoProvider. | | useNotifications | Hook | Lists notifications with cursor pagination and exposes markAsRead, markAsUnread, markAllAsRead, archive, snooze, fetchMore. New real-time notifications matching the active filters are prepended automatically. | | useUnreadCount | Hook | Tracks the subscriber's unread count, kept current via real-time events. | | usePreferences | Hook | Reads and mutates subscriber notification preferences, with optional workspaceId scoping. Exposes updatePreference and resetPreferences. | | useToast | Hook | Collects incoming real-time notifications into an auto-dismissing toast queue. Exposes add, dismiss, clear and accepts duration / maxSize options. | | useClientEvent | Hook | Subscribes to an arbitrary EmitoClient event with automatic cleanup on unmount. |

Each hook ships its accompanying types — UseNotificationsParams, UseNotificationsResult, UseUnreadCountResult, UsePreferencesOptions, UsePreferencesResult, ToastItem, UseToastOptions, UseToastResult, and EmitoProviderProps.

Part of Emito

@emito/react-hooks is one package in the Emito monorepo — self-hosted, provider-agnostic notification infrastructure for Node.js and TypeScript.

License

MIT — part of the Emito project.