Skip to main content
React Query v3 brings significant improvements, better SSR support, and many new features while refining the API based on community feedback.

Overview of Changes

Architecture

Scalable and testable cache configuration with separated QueryCache and MutationCache

SSR Support

Improved server-side rendering capabilities

Data Lag

Keep previous data visible while new data loads (replaces usePaginatedQuery)

Bi-directional

Infinite queries can now paginate in both directions

Selectors

Query data selectors for transformation and memoization

useQueries

New hook for variable-length parallel query execution

Breaking Changes

QueryCache Split into QueryClient and Caches

The QueryCache has been split into QueryClient, QueryCache, and MutationCache:
Benefits:
  • Different types of caches
  • Multiple clients with different configurations can share the same cache
  • Cleaner API focused on general usage
  • Easier to test individual components

New QueryClientProvider

Note the change from defaultConfig to defaultOptions.

Default QueryCache Removed

prefetchQuery Changed

Error Boundaries

Cache Methods Renamed

isFetching is Now a Method

useQueryCacheuseQueryClient

Query Functions No Longer Receive Split Parameters

Infinite Query Page Params

usePaginatedQuery Removed

Use keepPreviousData option instead:

Infinite Queries are Bi-directional

Changes:
  • getFetchMoregetNextPageParam
  • canFetchMorehasNextPage
  • fetchMorefetchNextPage
  • isFetchingMoreisFetchingNextPage
  • Added getPreviousPageParam, hasPreviousPage, fetchPreviousPage, isFetchingPreviousPage
  • Data is now { pages: [...], pageParams: [...] }

useMutation Returns Object

mutate No Longer Returns Promise

Query Options Collapsed

enabled Must Be Boolean

initialStale Option Removed

Initial data now respects staleTime:

refetchOnMount Scoped to Component

notifyOnStatusChange Replaced

clear() Renamed to remove()

updatedAt Split

setConsole() Replaced

React Native Auto-Configuration

React Native error logging is now automatic (no need to override console).

TypeScript: QueryStatus is Union Type

Enum values to string literals:
  • QueryStatus.Idle'idle'
  • QueryStatus.Loading'loading'
  • QueryStatus.Error'error'
  • QueryStatus.Success'success'

New Features

Query Data Selectors

Combine with notifyOnChangeProps for optimal performance:

useQueries Hook

Mutation Retry & Offline Support

Persist Mutations

Mutations can be persisted and resumed:

Query Observers

Watch queries outside React:
Also available:
  • InfiniteQueryObserver
  • QueriesObserver
  • MutationObserver

Pre-Configure Queries

Pre-Configure Mutations

useIsFetching with Filters

Core Separation

Use React Query core without React:

Devtools in Main Package

Migration Checklist

1

Update QueryCache to QueryClient

Replace all QueryCache instantiation with QueryClient.
2

Update Providers

Replace ReactQueryCacheProvider and ReactQueryConfigProvider with QueryClientProvider.
3

Update Hook Names

  • useQueryCacheuseQueryClient
  • usePaginatedQueryuseQuery with keepPreviousData
4

Update Infinite Queries

Rename properties and update to use pages data structure.
5

Update Mutations

Change from array to object destructuring.
6

Update Query Function Signatures

Use inline functions or QueryFunctionContext.
7

Update Options

Flatten config into main options object.
8

Update Method Names

  • getQueryfind
  • getQueriesfindAll
  • clearremove
9

Test Everything

Thoroughly test all queries, mutations, and cache interactions.
v3 represents a major evolution of React Query with better architecture, improved TypeScript support, and many powerful new features.