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

@coaction/react

v4.0.0

Published

A Coaction integration tool for React

Readme

@coaction/react

Node CI npm license

English documentation · 中文文档

A Coaction integration tool for React

Installation

Install it with pnpm:

pnpm add coaction @coaction/react

Compatibility

@coaction/react currently supports React 17, 18, and 19.

The package intentionally uses use-sync-external-store/shim internally so the same published build can work across those React versions. Removing the shim would require dropping React 17 support in a future major release.

The repository compiles and runs representative observer() and tracked-selector fixtures with the stable React Compiler Babel plugin (pnpm test:react-compiler). The CI fixture mounts the compiled components under React 19 and verifies both sibling-path isolation and tracked-path updates, so compiler compatibility is exercised behaviorally rather than inferred from React 19 runtime support alone.

Usage

For local-only React stores, prefer the isolated entry so Worker/transport protocol code is not part of the consumer dependency graph:

import { create, observer } from '@coaction/react';

Use @coaction/react/shared when the store uses Coaction Worker/SharedWorker/custom transport features. The root @coaction/react entry remains backwards compatible and supports both modes.

import { create, observer } from '@coaction/react';

const useStore = create((set) => ({
  count: 0,
  label: 'counter',
  increment: () => set((state) => state.count++)
}));

const CounterComponent = observer(() => {
  const store = useStore();
  return (
    <div>
      <p>Count: {store.count}</p>
      <button onClick={store.increment}>Increment</button>
    </div>
  );
});

Wrap components with observer() when you want MobX/Vue-style automatic render tracking. Inside an observed render, useStore() does not subscribe to the whole store; the component re-renders only when the Coaction state/getters it read during render change. Without observer(), useStore() remains a whole-store subscription.

Object traversal is collapsed to the deepest value actually read, so state.user.profile.name does not retain broad user/profile subscriptions. When a Coaction object is returned by a selector or passed directly as a React element prop, that object path is marked terminal and nested changes invalidate it. If object identity itself is used only as an opaque hook dependency inside observer() (for example useMemo(..., [state.user])) while deeper fields are also read, prefer an explicit selector for that object identity.

For smaller render regions, use <Observer>:

import { Observer } from '@coaction/react';

const CounterValue = () => (
  <Observer>
    {() => {
      const store = useStore();
      return <span>{store.count}</span>;
    }}
  </Observer>
);

Explicit selectors use the same reactive path graph as observer(). After the selector commits, unrelated state paths do not rerun the selector; dynamic branches replace their dependency set on the next committed evaluation. Object-valued selector results subscribe to that terminal object path so nested changes still invalidate the selection.

If a selector reads an external/mutable adapter value that cannot establish a Coaction reactive-path dependency, the React adapter automatically falls back to the store subscription contract. This preserves compatibility without imposing whole-store selector reruns on normal immutable Coaction paths.

For selector-heavy components, autoSelector returns a cached selector map instead of values. Hook calls stay explicit:

const selectors = useStore.auto();

const CounterComponent = () => {
  const count = useStore(selectors.count);
  const increment = useStore(selectors.increment);
  return <button onClick={increment}>Count: {count}</button>;
};

useStore({ autoSelector: true }) is kept as an alias for useStore.auto().

autoSelector is generated from the store shape known during initialization. If your application adds new keys at runtime, prefer explicit selectors such as useStore((state) => state.dynamic[key]) for those paths instead of expecting the cached selector map to grow dynamically.

Documentation

You can find the documentation here.