Hummbitv1.x

What is Hummbit

Hummbit

hummbit is an immutable state manager with two public entrypoints:

  • hummbit (framework-agnostic API + typed initStore)
  • hummbit/react (React-specific API + useSelector, no Provider required)

The package supports two usage styles:

  • Store instance mode via initStore(...) (recommended for new code)
  • Global singleton mode via top-level getState / setState / mergeState

How these modes work in practice:

  • Store instance mode (initStore)

    • You create an explicit store instance (const userStore = initStore(...)) with its own initialState, actions, selectors, subscriptions, and state version.
    • Instances are isolated from each other: updates in userStore do not affect cartStore.
    • In hummbit/react, an instance also exposes store.useSelector, so components subscribe to that specific store instance only.
    • This is the best fit for modular architecture where each domain (auth, cart, profile) has its own typed store.
  • Global singleton mode (top-level API)

    • The app uses one shared default store accessed through getState, setState, mergeState, selector, and global useSelector from hummbit/react.
    • Typing is usually done via module augmentation: declare module "hummbit" { interface RootState { ... } }.
    • This mode is useful when you intentionally want one global state container and no explicit store instances.
    • Call configureGlobalStore(...) during app bootstrap, before the first state updates.

When to choose which:

  • Choose Store instance mode for isolation, modularity, testability, and clear domain boundaries.
  • Choose Global singleton mode for smaller apps that prefer a single shared state container.

Quick Checklist

  • Need isolated domain store? Use initStore.
  • Need React binding with no Provider? Use hummbit/react and store.useSelector.
  • Need one global store? Use module augmentation + top-level API.
  • Need DevTools/middleware? Configure at bootstrap.
Author: Alexey TolkachevLinkedIn