Reference

@reckona/mreact-query

39 public exports.

Function

Function__resetQueryClientForTestingfunction __resetQueryClientForTesting(): voidResets process-wide query runtime state for tests.FunctioncreateInfiniteQueryfunction createInfiniteQuery<TPage, TPageParam>(client: QueryClient, options: CreateInfiniteQueryOptions<TPage, TPageParam>): InfiniteQueryObserver<TPage, TPageParam>Creates a reactive infinite-query observer backed by a `QueryClient`. It stores pages in the main query entry, fetches extra pages with derived page keys, and reports `isFetchingNextPage` while pagination is in progress.FunctioncreateMutationfunction createMutation<TVariables, TData, TContext>(client: QueryClient, options: CreateMutationOptions<TVariables, TData, TContext>): MutationObserver<TVariables, TData>Creates a mutation observer with lifecycle hooks and optional query invalidation.FunctioncreateQueryfunction createQuery<TData>(client: QueryClient, options: CreateQueryOptions<TData>): QueryObserver<TData>Creates a reactive query observer backed by a `QueryClient`. The observer exposes a `ReadonlyCell` result, subscribes to exact cache updates, can auto-fetch in the browser, and must be disposed when the consuming scope ends.FunctioncreateQueryClientfunction createQueryClient(): QueryClientCreates an isolated query client for cache reads, fetches, mutations, hydration, and subscriptions.Functiondehydratefunction dehydrate(client: QueryClient): DehydratedQueryClientSerializes successful query entries so they can be embedded in server-rendered HTML.FunctiongetQueryClientfunction getQueryClient(): QueryClientReturns the current scoped query client on the server or the shared browser query client in the browser. Browser calls automatically hydrate from the mreact query state script when present.FunctionhashQueryKeyfunction hashQueryKey(queryKey: QueryKey): stringCreates the stable string hash used to index a query key in the cache.Functionhydratefunction hydrate(client: QueryClient, dehydrated: DehydratedQueryClient): voidRestores dehydrated query entries into a query client before observers read them.FunctioninstallQueryAsyncStoragefunction installQueryAsyncStorage(storage: QueryAsyncStorage<QueryClient>): voidInstalls custom async storage for server-scoped query clients.FunctionisQueryClientScopeUnavailableErrorfunction isQueryClientScopeUnavailableError(error: unknown): error is QueryClientScopeUnavailableErrorChecks whether an error came from missing server query-client async storage.FunctionrunWithQueryClientfunction runWithQueryClient<T>(client: QueryClient, fn: (): T): TRuns a callback with a server-scoped query client. Node runtimes need `AsyncLocalStorage` support or a custom storage installed with `installQueryAsyncStorage()`.FunctionsyncQueryClientAcrossTabsfunction syncQueryClientAcrossTabs(client: QueryClient, options: CrossTabQuerySyncOptions): (): voidInstalls optional same-origin query synchronization for a browser query client. The adapter mutates the provided client and returns a disposer that restores the original methods.

Interface

InterfaceCreateInfiniteQueryOptionsinterface CreateInfiniteQueryOptionsConfigures a reactive infinite query observer.InterfaceCreateMutationOptionsinterface CreateMutationOptionsConfigures a mutation observer with lifecycle callbacks and invalidation keys.InterfaceCreateQueryOptionsinterface CreateQueryOptionsConfigures a reactive query observer.InterfaceCrossTabQuerySyncOptionsinterface CrossTabQuerySyncOptionsConfigures optional same-origin query cache coordination across browser tabs.InterfaceDehydratedQueryinterface DehydratedQueryRepresents one successful query entry serialized for server-to-client hydration.InterfaceDehydratedQueryClientinterface DehydratedQueryClientRepresents the serializable query cache payload embedded in server-rendered HTML.InterfaceFetchQueryOptionsinterface FetchQueryOptionsConfigures a direct query fetch through a query client.InterfaceInfiniteQueryDatainterface InfiniteQueryDataStores the pages and page parameters held by an infinite query.InterfaceInfiniteQueryFunctionContextinterface InfiniteQueryFunctionContextProvides pagination parameters to an infinite query function.InterfaceInfiniteQueryObserverinterface InfiniteQueryObserverObserves paginated query data and exposes next-page, refetch, and disposal controls.InterfaceInfiniteQueryResultinterface InfiniteQueryResultDescribes the reactive result exposed by an infinite query observer.InterfaceInvalidateQueriesOptionsinterface InvalidateQueriesOptionsSelects query entries for invalidation, cancellation, or removal.InterfaceMutationObserverinterface MutationObserverObserves mutation state and exposes the mutation trigger.InterfaceMutationResultinterface MutationResultDescribes the reactive result exposed by a mutation observer.InterfaceQueryAsyncStorageinterface QueryAsyncStorageProvides the AsyncLocalStorage-compatible interface used for server-scoped query clients.InterfaceQueryClientinterface QueryClientProvides cache reads, fetches, invalidation, removal, and subscriptions for queries.InterfaceQueryEntryinterface QueryEntryStores the cache metadata and result state for one query key.InterfaceQueryFunctionContextinterface QueryFunctionContextProvides query key and cancellation signal data to a query function.InterfaceQueryObserverinterface QueryObserverObserves one query result and exposes refetch and disposal controls.InterfaceQueryResultinterface QueryResultDescribes the reactive result exposed by a query observer.InterfaceQuerySubscriptionOptionsinterface QuerySubscriptionOptionsConfigures cache subscription matching and idle garbage collection.

Type Alias

Type AliasMutationStatustype MutationStatus = "idle" | "pending" | "success" | "error"Represents the lifecycle state of a mutation observer result.Type AliasQueryErrorReasontype QueryErrorReason = "aborted" | "retry-exhausted" | "network" | "unknown"Classifies why a query fetch failed.Type AliasQueryKeytype QueryKey = readonly unknown[]Represents the structured key used to identify cached query data.Type AliasQueryStatustype QueryStatus = "pending" | "success" | "error"Represents the lifecycle state of a query entry or observer result.

Variable

Variable__MREACT_QUERY_STATE_SCRIPT_IDconst __MREACT_QUERY_STATE_SCRIPT_ID: "__mreact_query_state"Identifies the script element that carries dehydrated query state during hydration.