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

@natsail/react

v0.7.1

Published

React provider and hooks for NATSail runtimes and shared sessions.

Readme

@natsail/react

@natsail/react provides a NATSail provider, runtime status hooks, session selectors, Core hooks, JetStream hooks, and serial reducer hooks.

pnpm add react @natsail/core @natsail/session @natsail/jetstream @natsail/react

NatsProvider owns neither the runtime nor the session registry. The application closes both objects. NatsManagedProvider is the ownership-safe alternative: it creates both after commit, reuses the resource during React Strict Mode effect replay, and closes it after final unmount. fallback renders until the resource exists, and onCloseError receives a failed close.

Default managed cleanup uses closeNatsResources({ runtime, sessions }) from @natsail/session to start registry and runtime shutdown together so a pending session cannot postpone the runtime's deadline. Identity changes permit temporary overlap: the replacement starts without waiting for the previous resource to drain. A custom resource close() overrides this behavior and remains responsible for both lifetimes; it can delegate to the same helper. See the lifecycle upgrade notes.

<NatsManagedProvider
  identity={accountId}
  create={() => ({
    runtime: createNatsRuntime(runtimeOptions),
    sessions: createSessionRegistry({ idleCloseMs: 250 }),
  })}
>
  <App />
</NatsManagedProvider>

useNatsJetStreamSubscription() opens one registry-shared, checkpointed JetStream source. To select from a source, call useNatsSessionSelector(key, createJetStreamSessionSource(runtime, options), selector).

useNatsJetStreamReducer() accepts a validated reducing definition and returns its atomic replay/live snapshot. useNatsJetStreamReducerSelector() can schedule React notifications immediately, in a microtask, or on the next animation frame (the default for both reducer hooks, set with notifications). The underlying session still reduces every delivery serially; only rendering is coalesced.

Both reducer hooks also accept the shared batchPolicy and an optional NatsailScheduler. Count, byte, and time bounds affect React notification delivery only. Replay and recovery phase changes bypass live coalescing.

useNatsConnection() follows the runtime-owned connection for advanced nats.js operations without adding an application connection effect.

useNatsJetStreamProcessor() owns one explicit-ack processor lease. Pass null options to disable it without conditionally calling a hook; change the key when its consumer configuration changes. A replacement waits for the previous lease to close, so an owned consumer cannot be recreated while its prior lease is still deleting it. When processor recovery is enabled, the hook reports reconnecting and the restart count without requiring a React remount.

See the NATSail README for React examples.

License

Apache-2.0