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

@morphixai/store

v0.0.8

Published

Minimal observable store with React bindings — SSR-safe, reentrancy-guarded.

Readme

@morphixai/store

Class-based reactive store. No framework dependency, no proxy magic — a plain Store<T> subclass with get / set / patch / subscribe, a built-in computed cache, selector-scoped subscriptions, and an opt-in React adapter at @morphixai/store/react.

When to use

  • Cross-platform state (web + native + node + workers + CLI) where MobX or Zustand bring more surface and runtime weight than you want.
  • Domain stores that want explicit, debuggable mutation paths (set / patch) rather than auto-tracked proxies.
  • Layers reused outside React — Vue/Svelte/Solid bridges, background jobs, tests.

Install

npm install @morphixai/store

Quick start

import { Store } from '@morphixai/store';

interface CounterState {
  count: number;
  doubled: number;   // computed
}

class CounterStore extends Store<CounterState> {
  constructor() {
    super({ count: 0, doubled: 0 });
    this.computed('doubled', (s) => s.count * 2);
  }

  increment() {
    this.set('count', this.state.count + 1);
  }
}

const counter = new CounterStore();

counter.subscribe((next, prev) => console.log(prev.count, '→', next.count));
counter.increment();          // logs: 0 → 1

counter.doubled;              // 2 — computed values live on the instance
counter.state.count;          // 1 — plain values live on state

computed(key, fn) defines a getter on the store instance, not inside state. Read it as counter.doubled; counter.state.doubled returns whatever was passed to super() and never updates.

Selector subscriptions

Only fires when the selected slice changes:

const off = counter.subscribe(
  (s) => s.count,
  (next, prev) => console.log('count', prev, '→', next),
);

off();   // unsubscribe

Selectors read from state, so they select plain fields — selecting a computed name would read the stale state copy and never fire.

React

import { useStore } from '@morphixai/store/react';

function Counter() {
  const count = useStore(counter, (s) => s.count);   // selector — re-renders on count only
  return <button onClick={() => counter.increment()}>{count}</button>;
}

React is an optional peer dependency — install it only if you use this entry.

useStore(store) without a selector subscribes to the whole state.

Semantics

  • state is deeply readonly. Writes go through set(key, value) or patch({ ... }) — there is no proxy interception, so a missed set will not notify subscribers. That is the trade: explicit writes, no hidden tracking.
  • The internal state object is replaced on every change, so consumers can compare with Object.is to detect changes. This is what useSyncExternalStore relies on, and it is why the React binding is SSR-safe.
  • Computed values are cached on the instance and invalidated on every notify.
  • Reentrant writes from inside a subscriber are guarded — a listener that calls set will not corrupt the notification pass.

Subpath exports

| Entry | Contents | |---|---| | @morphixai/store | Store, types | | @morphixai/store/react | useStore |

License

MIT