Skip to Content
Effetch Query

Coming from TanStack Query

How TanStack Query's ideas and names map to Effetch Query.

If you know TanStack Query, most of what you know carries over: the vocabulary is the same, and so are many of the names. The following table maps TanStack Query's APIs to Effetch Query's:

TanStack QueryEffetch Query
queryOptions({ queryKey, queryFn })api.query(endpoint), or Query.make / Query.family({ key, run })
useQuery, useSuspenseQuerySame names; they return an AsyncResult
useQuery's data, error, isPending, isFetching, refetchuseQueryState: the same fields, with status narrowing data and error
useMutation, mutationOptionsuseMutation(api.mutation(endpoint, { … })), or Mutation.make
getQueryData, setQueryDataQuery.get, Query.set / Query.update (Effects); QueryClient.get(client, query)
mutate(variables, { onSuccess, onError })run(variables, { onSuccess, onFailure })
useMutation's variables; mutation scopevariables; concurrent: "queue" (per useMutation)
useIsFetching, useIsMutating, useMutationStateSame names; useMutationState(mutation) lists one mutation's runs in progress
query(); ensureQueryData, fetchQuery (deprecated since 5.102)Query.fetch; outside Effect, client.fetch
prefetchQuery (deprecated since 5.102)Query.prefetch; outside Effect, client.prefetch
invalidateQueries, refetchQueries, resetQueriesQuery.invalidate, Query.refetch, Query.reset: a query, a family, a key prefix or a group
invalidateQueries in a mutation's onSuccessinvalidates on the mutation; fromClient(Api, { invalidates: "route" }) for every endpoint
removeQueries, queryClient.clear()Query.clear, client.clear(): drops the values without fetching
useQueryErrorResetBoundary with an error boundary and SuspenseQueryBoundary; with a router's boundary, useResetQueryFailure
focusManager, onlineManagerThe client's signals (Signals.browser, reactNativeSignals)
new QueryClient({ defaultOptions })QueryClient.make({ queries: { defaults }, mutations: { defaults } })
QueryCache({ onError, onSuccess, onSettled })queries.onFailure, queries.onSuccess, queries.onSettled
MutationCache({ onMutate, onError, … })mutations.onMutate, mutations.onFailure, …
selectselect on useQuery, useSuspenseQuery and useQueryState; Atom.map to share it
enabled: falseuseQuery(null)
placeholderData: keepPreviousDatauseQuery(query, { keepPrevious: true })
placeholderData from the cacheplaceholder on api.query, Query.make / Query.family
isPlaceholderDataisPlaceholder on useQueryState
useQueries; subscribed: falseuseQueries; paused: true on the reading hooks
retry: 3retry: Schedule (default none)
onMutate returning a rollback contextoptimistic, undone automatically
dehydrate, hydrate, HydrationBoundaryQueryClient.dehydrate, QueryClient.hydrate, HydrationBoundary; queries need a schema
setupRouterSsrQueryIntegrationconnectQueryClient (./react/tanstack-router)
useInfiniteQuery, fetchNextPageapi.infiniteQuery, useInfiniteQuery, InfiniteQuery.fetchNextPage
getNextPageParam, getPreviousPageParamnextPageParam, previousPageParam (return undefined / null for none)
setQueriesDataQuery.update(family, (value, args) => …)
A record in many queries (normalized caches, TanStack DB)Entity.update, Entity.set, Entity.remove, Entity.get
setQueryData on other queries in a query's onSuccessentities: { sync: [Todos] } on the client (Keep copies in sync)
experimental_streamedQueryQuery.stream, Query.streamFamily; api.query of an SSE or NDJSON endpoint
setQueryData from a WebSocket's messageslive on api.query, Query.make / Query.family
cancelQueries, devtoolsNot in 0.1