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

stoic-store

v1.0.0

Published

Minimal and powerful React state manager. Tiny, intuitive, and fully TypeScript-ready.

Readme

Stoic


Stoic is a small state management library for React, built on useSyncExternalStore. You define state and actions much like you would with any store library, but Stoic also lets you declare derived state — values computed from other state — as part of the store itself.

The key difference from most state managers: Stoic tracks the relationships between your state automatically. When something changes, only the derived values that actually depend on it are recomputed, and only the components reading those values rerender. There are no dependency arrays to maintain.

  • ⚡️ Plain function actions — no dispatch, no action types
  • 🧠 Reactive derived state with automatic dependency tracking
  • 🚀 First-class async actions, with built-in pending/error status and AbortSignal cancellation
  • 🔌 A small plugin system (persist and devtools are included; write your own for the rest)
  • 💙 Fully typed, with state and action arguments inferred by your editor

Installation

npm install stoic-store

Requires React 18+. Published as ESM only. See Installation.

Usage

import { createStore } from "stoic-store";

type State = { items: CartItem[]; tax: number };
type Derived = { subtotal: number; total: number };

export const cart = createStore<State, Derived>({
  state: {
    items: [{ id: 1, title: "Keyboard", price: 100 }],
    tax: 0.2,
  },

  derived: {
    subtotal: ({ items }) => items.reduce((sum, item) => sum + item.price, 0),
    total: ({ subtotal, tax }) => subtotal * (1 + tax),
  },
});

export const { addItem } = cart.actions({
  addItem: ({ set }, item: CartItem) => {
    set((s) => ({ items: [...s.items, item] }));
  },
});

Read it in a component — it only rerenders when total changes:

import { useStore } from "stoic-store/react";

function CartSummary() {
  const total = useStore(cart, (state) => state.total);

  return <h2>Total: ${total}</h2>;
}

And update it by calling the action like a regular function:

addItem({ id: 2, title: "Mouse", price: 50 });

subtotal and total recompute automatically whenever items or tax change — you never write that logic yourself.

Why Stoic

Most React state managers give you a store and leave computed values to you — so subtotal ends up as a useMemo in one component, a selector in another, and a hand-maintained dependency array in both. Stoic's premise is that a value computed from state belongs in the store, declared once, with the dependency graph worked out for you.

That's the whole pitch: one store object, plain-function actions, and declared derived state with automatic dependency tracking — in 2.4 kB gzipped, with no runtime dependencies.

Stoic is a good fit if you have real computed state (totals, filtered lists, aggregate stats), you want it typed end to end, and you'd rather have one store per domain than a graph of atoms.

Reach for something else if you want the smallest possible store and don't need derived state (Zustand is smaller); you prefer bottom-up, atom-level granularity (Jotai); you want to mutate state directly (Valtio); or you need middleware and conventions of a large app framework (Redux Toolkit).

Two honest trade-offs, up front:

  • Derived stores need their types spelled outcreateStore<State, Derived>. This is a TypeScript limitation, not a temporary one; the reasoning is documented.
  • Dependency tracking is per top-level key and compares by reference, so mutating state in place (state.items.push(x)) won't recompute anything. Replace, don't mutate.

Documentation

Full documentation lives in docs/.

| | | | --- | --- | | Getting started | Installation · Quick Start · Core Concepts | | Guides | Reading State · Actions · Derived State · Batching · Per-instance Stores · TypeScript · Testing | | Plugins | Overview · devtools · persist · Writing a plugin | | Reference | API Reference · FAQ · Versioning · Philosophy |

Runnable applications are in examples/: a shopping cart, a GitHub user search, and a kanban board. Run yarn build at the repository root first — they resolve Stoic from dist/.

Contributing

Issues, discussions, ideas, and pull requests are always welcome — open one on the issue tracker.

If you're sending a pull request, CONTRIBUTING.md covers setup, the commands, and what a change is expected to come with (tests, a changeset, and a benchmark if you touched a hot path).

If Stoic makes your React code simpler, consider giving the project a ⭐️ on GitHub.

License

MIT © peakercope