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

@pulse-js/react

v0.2.0

Published

React integration for the Pulse reactivity ecosystem. Provides hooks and utilities to consume Pulse Sources and Guards within React components efficiently.

Readme

@pulse-js/react

React integration for the Pulse reactivity ecosystem. Provides hooks and utilities to consume Pulse Sources and Guards within React components efficiently.

Features

  • Concurrent Mode Compatible: Built with useSyncExternalStore for compatibility with React 18+ concurrent features.
  • Zero Polling: Logic driven by direct subscriptions to the Pulse core, ensuring updates happen exactly when state changes.
  • Type Safety: Full TypeScript support for inferred types from Sources and Guards.

Installation

npm install @pulse-js/react @pulse-js/core

Usage

The primary API is the usePulse hook. It adapts automatically depending on whether you pass it a Source or a Guard.

Using Sources

When used with a Source, usePulse returns the current value and triggers a re-render whenever that value updates.

import { source } from "@pulse-js/core";
import { usePulse } from "@pulse-js/react";

const counter = source(0);

function Counter() {
  const value = usePulse(counter);

  return (
    <button onClick={() => counter.update((n) => n + 1)}>Count: {value}</button>
  );
}

Using Guards

When used with a Guard, usePulse returns the complete GuardState object, which includes status, value, and reason. This allows you to handle loading and error states declaratively.

import { guard } from "@pulse-js/core";
import { usePulse } from "@pulse-js/react";

const isAuthorized = guard("auth-check", async () => {
  // ... async logic
});

function ProtectedRoute() {
  const { status, reason } = usePulse(isAuthorized);

  if (status === "pending") {
    return <LoadingSpinner />;
  }

  if (status === "fail") {
    return <AccessDenied message={formatReason(reason)} />;
  }

  return <AdminDashboard />;
}

Rendering Failure Reasons

The reason property in a GuardState can be a string or a GuardReason object. To render it safely in JSX, use the formatReason helper:

import { formatReason } from "@pulse-js/react";

<p className="error">{formatReason(reason)}</p>;

Developer Tools

Pulse provides a dedicated inspector for debugging your reactive graph. In React applications, you can enable it with zero configuration.

Auto-Injection (Recommended)

Simply import @pulse-js/react/devtools at the top of your main entry point (e.g., main.tsx). The inspector will automatically mount to the DOM only in development environments (NODE_ENV === 'development').

import "@pulse-js/react/devtools";

Manual Component

Alternatively, you can use the PulseDevTools component for more control:

import { PulseDevTools } from "@pulse-js/react/devtools";

function App() {
  return (
    <>
      <MyRoutes />
      <PulseDevTools shortcut="Ctrl+D" />
    </>
  );
}

API

usePulse<T>(unit: PulseUnit<T>): T | GuardState<T>

  • Arguments:
    • unit: A Pulse Source or Guard.
  • Returns:
    • For Sources: The inner value T.
    • For Guards: An object { status: 'ok' | 'fail' | 'pending', value?: T, reason?: string }.

Performance

@pulse-js/react leverages modern React 18 patterns to ensure optimal performance. It avoids unnecessary re-renders by strictly tracking object references and using the useSyncExternalStore API to integrate with React's scheduling system.