@triggery/zustand
Read a Zustand store from a Triggery condition. Pull-only — the selector runs at fire time, not on every store update, so the host component is never re-rendered because of this hook.
Install
Section titled “Install”pnpm add @triggery/core @triggery/react @triggery/zustand zustand npm install @triggery/core @triggery/react @triggery/zustand zustand yarn add @triggery/core @triggery/react @triggery/zustand zustand bun add @triggery/core @triggery/react @triggery/zustand zustand Peer deps: react >= 18.0.0, zustand ^4 || ^5.
What’s inside
Section titled “What’s inside”| Export | Purpose |
|---|---|
useZustandCondition(trigger, name, store, selector) | Register a Zustand-backed condition. Works with both create (hook) stores and createStore (vanilla) stores. |
Quick example
Section titled “Quick example”How it works
Section titled “How it works”The runtime is pull-only: selector(store.getState()) is called only when a trigger fires, not when the store changes. That means:
- Nothing in your React tree re-renders because of this hook. If a component also needs the same slice, call Zustand’s own
useStore(store, selector)alongside. - The trigger always sees the latest state at fire time — no subscription, no possibility of a stale snapshot.
Related packages
Section titled “Related packages” @triggery/core Exposes Trigger.
@triggery/react useZustandCondition is a React hook.
@triggery/redux Alternative adapter for Redux stores.
@triggery/jotai Alternative adapter for Jotai atoms.
@triggery/mobx Alternative adapter for MobX observables.