Skip to content

React Query Overview

@chimeric/react-query provides factory functions that create chimeric queries, mutations, and infinite queries backed by TanStack Query v5+.

Each factory produces an object with both an idiomatic path (async/await) and a reactive path (.useHook() inside React components), sharing the same underlying TanStack Query cache.

Terminal window
npm install @chimeric/react-query @tanstack/react-query
FactoryCreatesIdiomaticReactive
ChimericQueryFactoryCached queryawait query(params)query.useHook(params)
ChimericMutationFactoryMutationawait mutation(params)mutation.useHook()
ChimericInfiniteQueryFactoryPaginated queryawait query(params)query.useHook(params)
ChimericAsyncReducerDerived async valueawait reducer(params)reducer.useHook(params)

Each chimeric factory also has Idiomatic-only and Reactive-only variants (e.g., IdiomaticQueryFactory, ReactiveQueryFactory) if you only need one execution path.

All factories accept a two-level options structure as a second argument:

// Idiomatic
await query(params, {
options: { forceRefetch: true }, // chimeric options
nativeOptions: { staleTime: 0 }, // TanStack Query options
});
// Reactive
query.useHook(params, {
options: { enabled: true }, // chimeric options
nativeOptions: { refetchInterval: 5000 }, // TanStack Query options
});

@chimeric/react-query uses the react-server export condition. When your bundler resolves imports for a server component, it automatically uses a server-safe build where hooks throw descriptive errors if accidentally called. No separate import path is needed — the same import { ... } from '@chimeric/react-query' works in both contexts.

See the Next.js guide for the full pattern.