Reference
@reckona/mreact-query
57 public exports.
Function
Function__resetQueryClientForTesting
function __resetQueryClientForTesting(): voidResets process-wide query runtime state for tests.FunctioncreateFormMutationFlowfunction createFormMutationFlow<TValues, TSubmitValues, TData, TQueryData>(client: QueryClient, form: MutationFlowForm<TValues, TSubmitValues>, options: FormMutationFlowOptions<TValues, TSubmitValues, TData, TQueryData>): FormMutationFlow<TValues, TSubmitValues, TData>Joins form validation, a server mutation, query invalidation, and optional optimistic record edits.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, TQueryKey>(client: QueryClient, definition: QueryDefinition<TData, TQueryKey>, options?: CreateQueryDefinitionOptions<TData>): QueryObserver<TData> function 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(options?: QueryClientOptions): QueryClientCreates an isolated query client for cache reads, fetches, mutations, hydration, and subscriptions.Functiondehydratefunction dehydrate(client: QueryClient, options: DehydrateOptions): 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 ErrorChecks whether an error came from missing server query-client async storage.FunctionqueryDefinitionfunction queryDefinition<TQueryKey, TData>(queryKey: TQueryKey, queryFn: (context: QueryFunctionContext<TQueryKey>): TData | Promise<TData>): QueryDefinition<TData, TQueryKey>Creates a reusable, type-linked query definition for cache and fetch APIs.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
InterfaceCreateInfiniteQueryOptions
interface 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.InterfaceDehydrateOptionsinterface DehydrateOptionsSelects successful query entries that may be serialized for browser hydration.InterfaceErrorQueryResultinterface ErrorQueryResultDescribes an error result exposed by a query observer.InterfaceFetchQueryOptionsinterface FetchQueryOptionsConfigures a direct query fetch through a query client.InterfaceFormMutationFlowinterface FormMutationFlowExposes form submission and the underlying mutation state.InterfaceFormMutationFlowOptionsinterface FormMutationFlowOptionsConfigures a form submission linked to a server mutation and query cache.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.InterfaceMutationFlowForminterface MutationFlowFormThe subset of a form needed to validate and submit a mutation.InterfaceMutationFlowServerErrorsinterface MutationFlowServerErrorsField and form errors returned by a server mutation.InterfaceMutationObserverinterface MutationObserverObserves mutation state and exposes the mutation trigger.InterfaceMutationResultinterface MutationResultDescribes the reactive result exposed by a mutation observer.InterfacePendingQueryResultinterface PendingQueryResultDescribes the pending result exposed by a query observer.InterfaceQueryAsyncStorageinterface QueryAsyncStorageProvides the AsyncLocalStorage-compatible interface used for server-scoped query clients.InterfaceQueryClientinterface QueryClientProvides cache reads, fetches, invalidation, removal, and subscriptions for queries.InterfaceQueryClientOptionsinterface QueryClientOptionsSets client-wide retention defaults for entries without active observers.InterfaceQueryDefinitioninterface QueryDefinitionBinds one query key to the data returned by its query function.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.InterfaceQueryResultBaseinterface QueryResultBaseInterfaceQuerySubscriptionOptionsinterface QuerySubscriptionOptionsConfigures cache subscription matching and idle garbage collection.InterfaceSuccessQueryResultinterface SuccessQueryResultDescribes a successful result exposed by a query observer.Type Alias
Type AliasCreateQueryDefinitionOptions
type CreateQueryDefinitionOptions = Omit<CreateQueryOptions<TData>, "queryKey" | "queryFn">Options applied when creating an observer from a query definition.Type AliasFormMutationFlowResulttype FormMutationFlowResult = { data: TData; status: "success" } | { status: "duplicate" } | { errors: Partial<Record<Extract<keyof ..., string> | "root", string[]>>; status: "invalid" } | { errors: MutationFlowServerErrors<TValues>; status: "server-errors" } | { error: unknown; status: "error" }The result of submitting a form-backed mutation.Type AliasMutationFlowServerResulttype MutationFlowServerResult = { data: TData; ok: true } | { errors: MutationFlowServerErrors<TValues>; ok: false }A validated server mutation result.Type AliasMutationStatustype MutationStatus = "idle" | "pending" | "success" | "error"Represents the lifecycle state of a mutation observer result.Type AliasQueryDefinitionDatatype QueryDefinitionData = TDefinition extends QueryDefinition<infer TData, QueryKey> ? TData : neverInfers the cached data type associated with a query definition.Type AliasQueryDefinitionFetchOptionstype QueryDefinitionFetchOptions = Omit<FetchQueryOptions<TData>, "queryKey" | "queryFn">Options applied when fetching a query definition.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 AliasQueryResulttype QueryResult = PendingQueryResult | SuccessQueryResult<TData> | ErrorQueryResult<TData>Describes the discriminated reactive result exposed by a query observer.Type AliasQueryStatustype QueryStatus = "pending" | "success" | "error"Represents the lifecycle state of a query entry or observer result.