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

pulsify-react

v20.0.0

Published

Fine-grained React rendering for Pulsify documents.

Readme

pulsify-react

Fine-grained React rendering for Pulsify documents, with no dependency besides React and pulsify-core.

import { usePulse } from "pulsify-react";
import { memo } from "react";

function Note({ note }: { note: typeof doc }) {
  const snap = usePulse(note);
  return (
    <>
      <input value={snap.title} onChange={(e) => (snap.title = e.target.value)} />
      <ul>{snap.items.map((item) => <Item key={item.label} item={item} />)}</ul>
    </>
  );
}

const Item = memo(({ item }: { item: (typeof doc)["items"][number] }) => (
  <li onClick={() => (item.done = !item.done)}>{item.label}</li>
));

useLoadPulse(definition, id, options?) loads a pulse under <Suspense>:

function NotePage({ id }: { id: string }) {
  const note = useLoadPulse(Note, id); // suspends until loaded
  return <h1>{note.title}</h1>;
}

It returns a pulse loaded or created already at once, loads again when the ID changes, and throws a failed load to the nearest error boundary, loading again on a later render (React's immediate retry sees the same error). Loads are kept per scope: components loading one ID in different scopes (options.scope) never wait for, or fail with, each other's load. Then it works as usePulse.

usePulse(pulse) returns a proxy of the live pulse that records what the component reads. Local and remote changes re-render it only when one of those values changed. Writes go straight to the pulse.

  • Objects, arrays, maps, counters, rich/plain text and trees keep their identity while nothing read below them changes, including after an array move, so memo children skip. A child reading a value it received records the read for the component that called usePulse.
  • Counters, plain/rich text and trees are compared by node revision in O(1): their readers re-render when their content changes. Maps track per key (get, has), size, and key iteration (keys, entries, values, forEach). Bind editors with pulsify-prosemirror, pulsify-lexical or pulsify-codemirror.
  • The pulse itself is renewed on every render, so a memo child given the whole pulse renders with its parent. Pass it the part it shows, or let it call usePulse on what it received.
  • A nested object passed to a skipped memo child keeps that child's reads until something below it changes, which costs at most one extra render.
  • Pulses live on the client. During server rendering, both hooks throw and the nearest <Suspense> boundary renders its fallback, then the client renders the content.
  • Do not write during render. Reads made in event handlers or effects are tracked too and can cause extra renders.

Presence

import { usePulsePresence } from "pulsify-react";

function Cursors({ project }: { project: ProjectPulse }) {
  const cursors = usePulsePresence(project, Cursor); // a definePresence channel
  return (
    <div onPointerMove={(e) => cursors.set({ x: e.clientX, y: e.clientY })}>
      {cursors.others.map(({ peer, state }) => (
        <i key={peer} style={{ left: state.x, top: state.y }} />
      ))}
    </div>
  );
}

usePulsePresence(pulse, channel) joins the channel while the component is mounted and returns { others, mine, set }. The component re-renders when the others or its own state change, not when the document does. A peer whose state did not change keeps the same object, so memo children skip.

  • set keeps its identity between renders, while the pulse and the channel stay the same. Call it from handlers and effects, never during render. A state set by a child's effect before the channel is joined is kept and sent.
  • Joins are counted: several components can use the same channel, and the state is removed when the last one unmounts.
  • Like usePulse, it renders on the client only.