unstale

npm / @tanstack/react-query

@tanstack/react-query

What changed in @tanstack/react-query 4 to 5, from its official release notes, upgrade guides and advisories. Sources checked 2026-11-30.

78 breaking8 deprecations15 new APIs and options1 performance14 behavior and defaults2 tooling20 fixes and other

See which of these apply to your code, ranked, in your agent:

npx @unstale/cli init

@unstale/cli on npm

@tanstack/react-query 598 changes

Breaking changes 51

  • The status filter is no longer accepted by QueryClient.isMutating, useIsMutating, or injectIsMutating; these APIs always count mutations with status: 'pending'.

    5.105.2release notes

  • Excludes fetchStatus from filters accepted by QueryClient.isFetching, useIsFetching, and injectIsFetching; these APIs always count queries with fetchStatus: 'fetching'.

    5.105.1release notes

  • The unused experimental_afterQuery hook has been removed.

    5.102.0release notes

  • The unused experimental_beforeQuery hook has been removed.

    5.102.0release notes

  • The promise property has been removed from query results.

    5.102.0release notes

  • Experimental render-time prefetching has been removed.

    5.102.0release notes

  • placeholderData has been removed from suspense infinite queries.

    5.102.0release notes

  • Adds environmentManager.

    5.91.0release notes

  • Renamed to gcTime, which more clearly describes the duration before unused query data is garbage collected.

    5.0.0upgrade guideupgrade guide

  • Removed from QueryClientProvider; share a queryClient instance directly across packages instead.

    5.0.0upgrade guide

  • The custom context prop for hooks was removed; pass a custom queryClient instance to achieve isolation.

    5.0.0upgrade guideupgrade guide

  • The deprecated custom logger support has been removed; logging only had an effect in development mode.

    5.0.0upgrade guideupgrade guide

  • Removed; use shouldDehydrateMutation to control mutation dehydration.

    5.0.0upgrade guideupgrade guide

  • Removed; use shouldDehydrateQuery to control query dehydration.

    5.0.0upgrade guideupgrade guide

  • Error is now the default TypeScript error type instead of unknown; specify a generic for other thrown values.

    5.0.0upgrade guideupgrade guide

  • Removed because object syntax is now the only supported syntax.

    5.0.0upgrade guideupgrade guide

  • Renamed from cacheTime; it controls how long unused query data remains before garbage collection.

    5.0.0upgrade guideupgrade guide

  • Now required for infinite queries; returning null or undefined indicates there is no next page.

    5.0.0upgrade guideupgrade guide

  • Renamed from hashQueryKey; it also hashes mutation keys and can be used in mutation predicates.

    5.0.0upgrade guideupgrade guide

  • Renamed to hashKey.

    5.0.0upgrade guide

  • Renamed to HydrationBoundary.

    5.0.0upgrade guide

  • Replaces Hydrate and hydrates queries, but no longer hydrates mutations.

    5.0.0upgrade guide

  • Required for infinite queries and supplies the first pageParam, avoiding undefined being stored in the query cache.

    5.0.0upgrade guideupgrade guide

  • Removed from useQuery; use structuralSharing to provide equivalent custom data equality behavior.

    5.0.0upgrade guideupgrade guide

  • For queries, newly represents isPending && isFetching; isInitialLoading now has the same meaning and is deprecated.

    5.0.0upgrade guideupgrade guide

  • Replaces isLoading as the derived flag corresponding to the pending status for queries and mutations.

    5.0.0upgrade guideupgrade guide

  • Use this flag in place of isPreviousData when identifying placeholder data.

    5.0.0upgrade guideupgrade guide

  • Removed in favor of isPlaceholderData.

    5.0.0upgrade guide

  • The option is removed in favor of passing the keepPreviousData identity function to placeholderData.

    5.0.0upgrade guide

  • Manual pageParam overrides for fetchNextPage and fetchPreviousPage were removed; getNextPageParam is now required.

    5.0.0upgrade guideupgrade guide

  • Online status starts as true and is updated only from online and offline events, no longer relying on navigator.onLine.

    5.0.0upgrade guideupgrade guide

  • Removed from queries; mutation callbacks are unchanged.

    5.0.0upgrade guideupgrade guide

  • Its function receives previous query data, allowing an identity function to replace keepPreviousData; placeholder data puts the query into success state and leaves dataUpdatedAt at 0.

    5.0.0upgrade guideupgrade guide

  • Hooks can receive a custom queryClient instance directly to provide isolation previously achieved with a custom context.

    5.0.0upgrade guideupgrade guide

  • Now accepts only queryKey; the filters argument is no longer supported.

    5.0.0upgrade guideupgrade guide

  • Now merges all matching registrations instead of returning only the first; order setQueryDefaults registrations from generic to specific.

    5.0.0upgrade guide

  • Now accepts only queryKey; the filters argument is no longer supported.

    5.0.0upgrade guideupgrade guide

  • React 18.0 or later is now required.

    5.0.0upgrade guide

  • Its callback now receives only the query, rather than data and query; access untransformed data through query.state.data.

    5.0.0upgrade guideupgrade guide

  • Removed in favor of maxPages for limiting the pages stored and refetched by infinite queries.

    5.0.0upgrade guideupgrade guide

  • Retries now default to 0 on the server, preventing server-executed queries from retrying.

    5.0.0upgrade guideupgrade guide

  • The loading status is now named pending for queries and mutations.

    5.0.0upgrade guideupgrade guide

  • Can now implement the custom equality behavior previously provided by isDataEqual.

    5.0.0upgrade guide

  • The experimental suspense boolean flag on query hooks has been removed; use the dedicated suspense hooks.

    5.0.0upgrade guide

  • Renamed from useErrorBoundary to describe the option's behavior in a framework-agnostic way.

    5.0.0upgrade guideupgrade guide

  • The minimum supported TypeScript version is now 4.7.

    5.0.0upgrade guideupgrade guide

  • No longer automatically set as the batching function in React and React Native; frameworks can register a custom function with notifyManager.setBatchNotifyFunction.

    5.0.0upgrade guide

  • Renamed to throwOnError.

    5.0.0upgrade guideupgrade guide

  • Removed; use the hydration APIs that remain available.

    5.0.0upgrade guide

  • Query hooks and related APIs now support only the single object signature; positional overloads must be migrated.

    5.0.0upgrade guideupgrade guide

  • Removed; use queryClient.removeQueries to remove a query instead.

    5.0.0upgrade guideupgrade guide

Deprecations 8

New APIs and options 10

  • Introduced an experimental fine-grained storage persister.

    5.0.0upgrade guide

  • Limits the number of pages stored in infinite query data and subsequently refetched.

    5.0.0upgrade guideupgrade guide

  • Allows a framework with a custom batching function to register it with TanStack Query.

    5.0.0upgrade guide

  • Infinite queries can prefetch multiple pages by specifying the pages option; by default, only the first page is prefetched.

    5.0.0upgrade guideupgrade guide

  • Introduced as the replacement for queryClient.fetchInfiniteQuery; the imperative fetch methods are deprecated and will be removed in v6.

    5.0.0upgrade guideupgrade guide

  • Function equivalent for controlling whether mutations are dehydrated.

    5.0.0upgrade guide

  • Function equivalent for controlling whether queries are dehydrated.

    5.0.0upgrade guide

  • A typesafe way to create query options is available.

    5.0.0upgrade guide

  • A new combine option is available for combining results from multiple queries.

    5.0.0upgrade guideupgrade guide

  • A stable dedicated suspense hook whose data is never potentially undefined at the type level.

    5.0.0upgrade guide

Performance 1

  • The browserslist was updated to target more modern browsers, producing a smaller and more performant bundle.

    5.0.0upgrade guide

Behavior and default changes 8

  • TData now defaults to InfiniteData<TQueryFnData> to match hook generics.

    5.102.0release notes

  • usePrefetchInfiniteQuery now uses queryClient.infiniteQuery for prefetching.

    5.102.0release notes

  • usePrefetchQuery now uses queryClient.query for prefetching.

    5.102.0release notes

  • Queries and mutations are always dehydrated by default; customize this behavior with shouldDehydrateQuery and shouldDehydrateMutation functions.

    5.0.0upgrade guide

  • Returning null, as well as undefined, indicates there is no previous page.

    5.0.0upgrade guide

  • Class fields and methods are now ECMAScript-private and cannot be accessed from outside at runtime.

    5.0.0upgrade guideupgrade guide

  • Query defaults are now shown set from the less specific key ['todo'] to the more specific key ['todo', 'detail']; this ordering matters when defining defaults.

    5.0.0upgrade guide

  • Window focus refetching now uses visibilitychange exclusively instead of listening to the focus event.

    5.0.0upgrade guide

Tooling 2

  • Codemods no longer copy unnecessary files from the codemods project.

    5.103.3release notes

  • A v5 codemod can migrate positional overloads to the object syntax; use the documented extensions, parser, and transform options for the source files being migrated.

    5.0.0upgrade guide

Fixes and other changes 18

  • Observer options are updated before subscribing, so revealing an <Activity> tree whose query key changed while hidden no longer fetches the previous key.

    5.105.2release notes

  • Corrects the overload selected when initialData may be undefined.

    5.105.1release notes

  • Results are recomputed when filters, selector, or query client change, without waiting for a mutation cache update.

    5.104.5release notes

  • Queries with falsy errors can retry on mount when throwOnError returns false.

    5.104.4release notes

  • Declare @types/react as an optional peer dependency of react-query packages.

    5.104.4release notes

  • useQueries and useSuspenseQueries now throw falsy errors to the error boundary.

    5.102.6release notes

  • Return types can be emitted in declaration files without leaking internal data tag symbols.

    5.102.0release notes

  • Type-only exports no longer emit a runtime import.

    5.102.0release notes

  • Mutation variables become optional when undefined extends TVariables.

    5.102.0release notes

  • Generic type parameters now propagate to the useMutationState select callback.

    5.102.0release notes

  • Unsubscribed useQueries no longer show optimistic fetching.

    5.102.0release notes

  • useQuery return types retain NoInfer.

    5.102.0release notes

  • React Query no longer enters optimistic fetching state when the query is not subscribed.

    5.100.14release notes

  • Suspense queries now skip calling combine, preventing combine from running when queries would suspend.

    5.100.3release notes

  • Resolved an issue involving the excluded build directory.

    5.94.5release notes

  • Maintains error state on reset refetch when initialData is defined.

    5.91.2release notes

  • Allows retryOnMount when throwOnError is a function.

    5.90.16release notes

  • Prevents infinite render loops when useSuspenseQueries has duplicate queryKeys.

    5.90.11release notes

@tanstack/react-query 440 changes

Breaking changes 27

  • The undocumented QueryClient method was removed.

    4.0.0upgrade guide

  • Imperative query-fetching methods now default cancelRefetch to true, cancelling an ongoing fetch and starting a new one; pass false to retain the previous behavior.

    4.0.0upgrade guide

  • The renamed asynchronous storage persister is available from @tanstack/query-async-storage-persister.

    4.0.0upgrade guide

  • The renamed synchronous storage persister is available from @tanstack/query-sync-storage-persister.

    4.0.0upgrade guide

  • The QueryClient method was removed; the functionality remains available through mutationCache.

    4.0.0upgrade guide

  • This method was removed because it did not actually cancel the outgoing request.

    4.0.0upgrade guide

  • Mutation keys must be arrays rather than strings.

    4.0.0upgrade guide

  • Queries and mutations pause by default when there is no network connection; setting networkMode: 'offlineFirst' opts into the previous behavior.

    4.0.0upgrade guide

  • The option no longer accepts 'tracked'; property tracking is the default, and 'all' opts out of smart tracking.

    4.0.0upgrade guide

  • This configuration option has been removed because tracked property notifications are now the default.

    4.0.0upgrade guide

  • setQueryData no longer calls onSuccess; the callback is tied to a request being made.

    4.0.0upgrade guide

  • The persistQueryClient interface formerly named Persistor is now named Persister.

    4.0.0upgrade guide

  • The legacy cancel method on promises is no longer supported; use the AbortController-based query cancellation API.

    4.0.0upgrade guide

  • This unused query method was removed.

    4.0.0upgrade guide

  • Query cache event names changed from queryAdded, queryRemoved, and queryUpdated to added, removed, and updated.

    4.0.0upgrade guide

  • Query keys must be arrays; string keys such as 'todos' must be changed to ['todos'].

    4.0.0upgrade guide

  • The separate hydration entry point was removed; import hydration utilities from @tanstack/react-query.

    4.0.0upgrade guide

  • The React-specific entry point was renamed from react-query/react to @tanstack/react-query/reactjs.

    4.0.0upgrade guide

  • invalidateQueries combines refetchActive and refetchInactive into refetchType, supporting active, inactive, all, or none.

    4.0.0upgrade guide

  • setLogger was removed; configure a logger through the logger field when creating a QueryClient.

    4.0.0upgrade guide

  • The idle status was removed; queries that were idle now report loading status and fetchStatus: 'idle'.

    4.0.0upgrade guide

  • Devtools are installed from a separate package instead of the react-query/devtools entry point.

    4.0.0upgrade guide

  • The react-query package was renamed; install and import @tanstack/react-query instead.

    4.0.0upgrade guide

  • Query filters use type: 'active' | 'inactive' | 'all' instead of the active and inactive boolean flags.

    4.0.0upgrade guide

  • TypeScript v4.1 or greater is now required.

    4.0.0upgrade guide

  • Successful queries may no longer store undefined as their cache value; returning undefined from a queryFn becomes a failed Promise, and the type system disallows it.

    4.0.0upgrade guide

  • The hook now accepts an object with a queries property containing the queries array.

    4.0.0upgrade guide

New APIs and options 5

  • Adds mutationOptions to React Query v4 for configuring mutations.

    4.44.0release notes

  • Adds usePrefetchInfiniteQuery to react-query.

    4.43.0release notes

  • Adds usePrefetchQuery to react-query.

    4.43.0release notes

  • Custom contexts can be specified for hooks and QueryClientProvider to pair them with the correct provider when multiple providers are in the component tree.

    4.0.0upgrade guide

  • Use isInitialLoading to identify disabled queries that have not loaded data, including when deciding whether to show a loading spinner.

    4.0.0upgrade guide

Behavior and default changes 6

  • Mutations can now be garbage collected automatically, with a default cacheTime of five minutes.

    4.0.0upgrade guide

  • Mutation cache events now use the same event types as QueryCacheNotifyEvent.

    4.0.0upgrade guide

  • Package exports support Node's native CommonJS and ESM resolution and restrict imports to officially supported entry points.

    4.0.0upgrade guide

  • Errors are no longer logged to the console in production; development-mode error logging remains.

    4.0.0upgrade guide

  • A functional updater can return undefined to bail out of an update instead of creating or changing a cached entry.

    4.0.0upgrade guide

  • Query properties are tracked by default to improve render optimization.

    4.0.0upgrade guide

Fixes and other changes 2

  • Updated to support React 19 as a peer dependency correctly.

    4.42.2release notes

  • React Query now has first-class support for React 18 and its concurrent features.

    4.0.0upgrade guide