Query
A ChimericQuery represents a cached read operation. Once instantiated via a React Query or RTK Query factory, usage is identical regardless of the backing library.
Idiomatic Path
Section titled “Idiomatic Path”Call the query as an async function:
// With paramsconst user = await getUser({ id: '123' });
// Without paramsconst todos = await getAllTodos();
// With chimeric optionsconst user = await getUser({ id: '123' }, { options: { forceRefetch: true } });
// With native library optionsconst user = await getUser({ id: '123' }, { nativeOptions: { staleTime: 0 } });Idiomatic options:
| Option | Type | Description |
|---|---|---|
options.forceRefetch | boolean | Bypass cache staleness and force a fresh fetch |
nativeOptions | library-specific | Passed directly to the underlying query library |
Prefetch
Section titled “Prefetch”Populate the cache without returning the result. Useful for warming the cache ahead of navigation.
await getUser.prefetch({ id: '123' });
// Without paramsawait getAllTodos.prefetch();Reactive Path
Section titled “Reactive Path”Use .useHook() inside a React component:
function UserProfile({ userId }: { userId: string }) { const { data, isPending, isError, error, refetch, native } = getUser.useHook( { id: userId }, { options: { enabled: !!userId } }, );
if (isPending) return <div>Loading...</div>; if (isError) return <div>Error: {error?.message}</div>; return <div>{data?.name}</div>;}Return value:
| Property | Type | Description |
|---|---|---|
data | TResult | undefined | Query result |
isPending | boolean | Initial loading state |
isIdle | boolean | No query has been made |
isSuccess | boolean | Query succeeded |
isError | boolean | Query errored |
error | TError | null | Error object |
refetch | () => Promise<TResult> | Manually trigger a refetch |
native | library-specific | Full result from the underlying query library |
Reactive options:
| Option | Type | Description |
|---|---|---|
options.enabled | boolean | Conditionally enable the query (default: true) |
nativeOptions | library-specific | Passed directly to the underlying query library |
Prefetch Hook
Section titled “Prefetch Hook”Prefetch data during render, before the subscribing component mounts:
getUser.usePrefetchHook({ id: nextUserId });See also: Suspense for useSuspenseHook.