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

statemesh-core

v1.0.1

Published

A TypeScript-first, transaction-first state orchestration library for React. Actions, computed state, async transactions, optimistic UI, rollback, persistence, URL state, forms, cross-tab sync, undo/redo, time travel, middleware pipelines, router, and tes

Readme


Why StateMesh?

One store for everything. State, server cache, forms, URL parameters, routing, cross-tab sync, undo history — all live in one store with one set of types. No more wiring together 5 libraries with different mental models.

Every state change is a transaction. Validate, optimistic update, effect, commit, rollback — all automatic. Retry with exponential backoff, timeout, and cancellation.

Subscriptions that never waste renders. Path-scoped selectors with equality checking. Updating cart.items does not rerender components reading theme.

Zero runtime dependencies. React is the only peer dependency.


Quick Start

npm install statemesh-core
import { createMesh, StateMeshProvider, useMeshState } from "statemesh-core";

const mesh = createMesh({
  state: { count: 0 }
});

function Counter() {
  const [count, setCount] = useMeshState<number>("count");
  return <button onClick={() => setCount(count + 1)}>Count: {count}</button>;
}

export function App() {
  return (
    <StateMeshProvider mesh={mesh}>
      <Counter />
    </StateMeshProvider>
  );
}

Features

| Feature | What it does | |---------|-------------| | State | External store with path-based subscriptions, useSyncExternalStore | | Actions | Named state mutations with payloads and handlers | | Selectors & Computed | Derived state, memoization, dependency tracking | | Transactions | Async lifecycle — validate, optimistic, effect, commit, rollback | | Undo / Redo | Automatic history tracking with configurable depth | | Time Travel | Replay to any point in time | | Middleware Pipelines | Intercept, transform, log, and guard state changes | | Resources | Cached API reads with deduplication, polling, pagination | | Mutations | Write operations with optimistic rollback and offline queue | | API Client | Built-in HTTP client with interceptors and retry | | Persistence | localStorage, sessionStorage, IndexedDB, cross-tab sync | | Forms | Async validation, schema adapters, field arrays, autosave | | URL State | Sync state with URL search params | | Router | Routing IS state management — transactions, loaders, guards | | DevTools | Timeline, profiler, diagnostics, state inspector | | Testing | Mock helpers, assertions, async utilities |


Example: Transaction with Optimistic UI

const checkout = mesh.transaction("cart.checkout", {
  optimistic(state) {
    state.cart.status = "processing";
  },
  async effect(state, payload, ctx) {
    return fetch("/api/checkout", { signal: ctx.signal });
  },
  commit(state, result) {
    state.order = result;
    state.cart.items = [];
  },
  rollback: true,
  retry: { attempts: 3, delay: backoff() }
});
function CheckoutButton() {
  const tx = useMeshTransaction(checkout);
  return (
    <button disabled={tx.pending} onClick={() => tx.run({ paymentMethodId: "card_1" })}>
      {tx.pending ? "Processing..." : "Pay now"}
    </button>
  );
}

Example: Router with Data Loading

const routes = defineRoutes([
  {
    path: "/products",
    component: () => import("./pages/Products"),
    loader: ({ mesh }) => mesh.resource("products.list").fetch(),
    children: [
      {
        path: ":id",
        component: () => import("./pages/ProductDetail"),
        loader: ({ params, mesh }) => mesh.resource("product.detail").fetch({ id: params.id })
      }
    ]
  }
]);
function Layout() {
  return (
    <div>
      <nav>
        <Link to="/products">Products</Link>
      </nav>
      <Outlet />
    </div>
  );
}

Documentation

Full documentation is available at react-statemesh.github.io/statemesh-docs

| Section | What's covered | |---------|---------------| | Guide | Installation, core concepts, TypeScript | | Core | State, actions, selectors, transactions, undo/redo | | Data | Resources, mutations, API client, persistence | | UI | Forms, URL state, error boundaries | | Router | Routes, navigation, guards, data loading, SEO | | Advanced | Middleware, guards, plugins, sync, devtools | | Testing | Test helpers and patterns | | Integration | Next.js, migration from other libraries | | API Reference | Error codes, events, changelog |


Test Coverage

603 tests across 19 test files covering every module, API surface, error path, and edge case.

pnpm test           # Full suite
pnpm test:types     # Type tests only
pnpm test:watch     # Watch mode

Production Notes

  • Zero runtime dependencies — React is a peer dependency
  • 100% TypeScript — type-safe paths, discriminated events, generic inference
  • SSR-safe — all browser APIs guarded, dehydrate/hydrate for server rendering
  • Tree-shakeable — router, devtools, and testing are separate entry points
  • Bounded memory — LRU caches, ring buffers, snapshot limits

License

MIT