Sticky

Simple and persistent state & fetch hooks built on Zustand and Immer.

useSticky

Razor-thin state management built on top of Zustand.

  • minimal to no boilerplate
  • mutations with Immer
  • built-in (optional) persistence (sessionStorage, localStorage)
  • doesn't care if mutations/actions are sync or async
  • supports selectors to prevent unnecessarily re-rerenders
  • no React context needed

useApi

Simple fetch hook heavily inspired by useSwr, shares the storage & mutations mechanisms used in useSticky.

  • support custom fetchers
  • configurable SWR or "non-SWR" cache (staleAfter and experieAfter)
  • built-in de-duplication for fetches
  • mutations are reflected to all hooks of the same url & fetcher combo
  • supports mapping (memoized)
  • easy to revalidate reactively, manually or with a refresh-interval

Why not just use useSwr? We really could. But since we already have Zustand (& Immer), it was relatively easy to implement something that covered our simple needs. Plus, one less dependency is always great. 🤓

useRemap 🧪

Experimental hook to combine multiple sources to one simple state.

This guide is based on version: 1.1.0