@triggery/query
Read cached TanStack Query data from a Triggery condition. Pull-only: queryClient.getQueryData(key) runs only when a trigger fires, the host component is never subscribed to cache updates.
Install
Section titled “Install”pnpm add @triggery/core @triggery/react @triggery/query @tanstack/query-core npm install @triggery/core @triggery/react @triggery/query @tanstack/query-core yarn add @triggery/core @triggery/react @triggery/query @tanstack/query-core bun add @triggery/core @triggery/react @triggery/query @tanstack/query-core Peer deps: react >= 18.0.0, @tanstack/query-core ^5. @tanstack/react-query re-exports query-core and works out of the box.
What’s inside
Section titled “What’s inside”| Export | Purpose |
|---|---|
useQueryCondition(trigger, name, queryClient, queryKey, selector?) | Register a condition backed by a cached TanStack Query entry. |
Quick example
Section titled “Quick example”With a projection selector:
How it works
Section titled “How it works”Pull-only: queryClient.getQueryData(key) runs only when a trigger fires, not on every cache update. The host component is never subscribed to the query — use useQuery / useQueryClient alongside in components that render the data.
When the cache entry is missing, the condition value is undefined, which fails a required gate cleanly and skips the handler instead of throwing.
Related packages
Section titled “Related packages” @triggery/core Exposes Trigger.
@triggery/react useQueryCondition is a React hook.
@triggery/zustand Adapter for non-server client state.
@triggery/redux Adapter for Redux state.
@triggery/socket Pair query cache reads with socket-driven invalidations.