Shared state and Occam's razor

It is futile to do with more things that which can be done with fewer. — Occam's razor There's a visible rift between the approaches to local state from React's useState() and shared state from the popular libs. In an attempt to quell my concerns, I turned Occam's razor to these libs, as they seemed to offer some room for that: Most libs bring quite an inventory of new entities: Redux Toolkit has store, slices, actions, reducers, selectors, and thunks; Jotai has atoms, stores, and own Provider; Zustand has stores, actions, selectors, and a hook factory; MobX has elaborate observables with a set of subtypes, actions, reactions, computeds; Most libs require substantial rewrites to move local state to shared state; Some libs also require additional workarounds for SSR. In my quest for a minimal approach to shared state, I ended up creating Groundstate. It's similar to useState(): focused on the single task of storing the state, flexible enough, and effortlessly compatible with SSR, while avoiding verbosity. Groundstate introduces just one new entity: store. See an example of Groundstate in action

Mar 26, 2025 - 21:50
 0
Shared state and Occam's razor

It is futile to do with more things that which can be done with fewer.
Occam's razor

There's a visible rift between the approaches to local state from React's useState() and shared state from the popular libs. In an attempt to quell my concerns, I turned Occam's razor to these libs, as they seemed to offer some room for that:

  • Most libs bring quite an inventory of new entities:
    • Redux Toolkit has store, slices, actions, reducers, selectors, and thunks;
    • Jotai has atoms, stores, and own Provider;
    • Zustand has stores, actions, selectors, and a hook factory;
    • MobX has elaborate observables with a set of subtypes, actions, reactions, computeds;
  • Most libs require substantial rewrites to move local state to shared state;
  • Some libs also require additional workarounds for SSR.

In my quest for a minimal approach to shared state, I ended up creating Groundstate. It's similar to useState(): focused on the single task of storing the state, flexible enough, and effortlessly compatible with SSR, while avoiding verbosity. Groundstate introduces just one new entity: store.

See an example of Groundstate in action