unistash

Introduction

A tiny, typed, zero-dependency React state library.

Introduction

unistash is a tiny, fully-typed React state library with zero dependencies. One package, one createStore, no providers or reducers.

npm install unistash
import { createStore } from "unistash";

const useCounter = createStore({
  state: { count: 0 },
  actions: { increment: (s) => ({ count: s.count + 1 }) },
  computed: { doubled: (s) => s.count * 2 },
});

function Counter() {
  const { count, doubled, increment } = useCounter();
  return <button onClick={increment}>{count} ({doubled})</button>;
}

State, computed values, and actions come back from one hook. Read everything with a bare call, or pass a selector for fine-grained re-renders.

  • Zero dependencies — nothing but React (a peer).
  • Fully typed — autocomplete on state, computed, and actions.
  • Selectors + SSR — built in.

Next: Quick start.

On this page