npm / @reduxjs/toolkit
@reduxjs/toolkit
What changed in @reduxjs/toolkit 2, from its official release notes, upgrade guides and advisories. Also covers @rtk-query/codegen-openapi. Sources checked 2026-11-30.
56 breaking5 deprecations61 new APIs and options7 performance17 behavior and defaults5 tooling62 fixes and other
See which of these apply to your code, ranked, in your agent:
npx @unstale/cli init@reduxjs/toolkit 2213 changes
Breaking changes 56
An endpoint's maxRetries now caps retries even when the API-level retry() has a retryCondition.
A pending entry restored from persisted state fetches again when no request is actually running.
A negative numeric polling interval now disables polling instead of causing immediate repeated polling.
In onQueryStarted, queryFulfilled rejects if the entry is removed while its request runs; callers awaiting it should handle rejection.
A shared query refetches if any subscriber's own or inherited setting is true; another subscriber's false no longer overrides it.
A value of 0 now always refetches instead of disabling the option.
Removing a cache entry during its request now aborts that request; initiate() resolves with an AbortError, and unwrap() rejects.
Resets only that store's RTK Query runtime, clearing its subscribers, timers, cache lifecycles and pending tag invalidations, and aborting its running requests.
Calling retry.fail() inside a backoff function no longer nests the error inside { error, meta }.
The missing-middleware check runs once per store and is stricter: another API with the same reducerPath does not satisfy the check.
Retriggering a mutation with the same fixedCacheKey ends the previous cache lifecycle so its cleanup runs; an earlier in-flight trigger's cacheDataLoaded rejects instead of remaining unsettled.
A query that failed before receiving data now reports isLoading: true when it refetches.
Synchronous throws are caught and logged with console.error instead of escaping the pending dispatch and preventing queryFn from running.
A custom responseHandler that throws or rejects with a falsy value now produces PARSING_ERROR instead of a successful response.
A timeout that fires while the response body is being read is reported as TIMEOUT_ERROR instead of PARSING_ERROR.
Its default payload type is now the listener options object, matching the action dispatched at runtime.
Aborts that happen before the pending action is dispatched are no longer swallowed.
RTK now uses TypeScript's built-in NoInfer utility, which is available with TypeScript 5.4 and later.
RTK calls setUseStrictIteration(false), so Immer copies only string keys in objects by default for RTK updates, improving performance; apps using symbol keys can call setUseStrictIteration(true) to restore the previous behavior.
Initiates requests without adding a subscription, so cache entries remain only for the keepUnusedDataFor period unless the app subscribes.
Dispatching resetApiState now aborts all in-flight requests.
store.dispatch now throws if an action's type is not a string.
Throws an error when ApiProvider is nested inside a normal Provider.
autotrackMemoize is no longer re-exported.
The combineReducers overloads are replaced by a single function definition that takes ReducersMapObject as its generic parameter.
The enhancers option must be provided as a callback.
When both middleware and enhancers are provided, middleware must appear first for internal TypeScript inference to work correctly.
The middleware array option was removed.
The enhancers field must now be a callback, which receives getDefaultEnhancers for customizing the default enhancers.
The middleware option now only accepts a callback, which can use getDefaultMiddleware to retain default middleware.
Tag invalidation is delayed by default so multiple invalidations can be handled together; set the flag to immediately to restore RTK 1.9 behavior.
The object lookup-table form is removed; use the builder callback form instead.
Uses weakMapMemoize as its default memoizer, offering an effectively infinite cache size for varying arguments but relying exclusively on reference comparisons.
The object form is removed; use the builder callback form instead.
The function was renamed to lruMemoize; update imports that customize selectors.
The Dictionary type has been removed.
Build artifacts now live under dist/ instead of separate top-level folders, and output targets modern ES2020 syntax without transpilation.
The lookup table is now typed as Record<Id, MyEntityType>, assuming each lookup exists by default; noUncheckedIndexedAccess can make lookups possibly undefined.
Using EntityState directly now requires both generic arguments.
Published JavaScript now targets ES2020; projects targeting older browsers must transpile the packages or use the legacy ESM artifact.
The standalone export is removed; use the function passed to the middleware callback instead.
The export is removed; use the action creator's static type property instead.
RTK no longer automatically enables Immer's ES5 fallback when loaded.
Renames defaultMemoize to lruMemoize for clarity; update imports if you used the function to customize selectors.
The middleware action parameter is now typed as unknown, so middleware must narrow it before accessing fields.
The middleware next parameter is now typed as (action: unknown) => unknown.
ParametricSelector and OutputParametricSelector types have been removed; use Selector and OutputSelector instead.
React-Redux v9 requires React 18 and no longer supports React 16 or 17, allowing it to drop the shim.
Custom useDispatch, useSelector, and useStore hooks are now configured together under hooks, and all three are required when the key is present.
Reducer now accepts a PreloadedState generic, defaulting to S, to represent the state passed on the reducer's first call.
The default export has been removed; import the named thunk and withExtraArgument exports instead.
Tag invalidations are delayed.
TypeScript now requires Tuple when passing custom middleware or enhancers to configureStore, preserving the types of individual entries; plain arrays remain valid in JavaScript.
The lowest TypeScript version tested is now 4.7.
UMD build artifacts are no longer included in the published package; browser-ready ESM is available at dist/$PACKAGE_NAME.browser.mjs.
UnknownAction treats fields other than action.type as unknown and is now the default where Redux expects an action object.
Deprecations 5
The internal action is deprecated, still works in 2.x with a one-time development warning, and is planned for removal in 3.0.
RTK Query's RootState type is deprecated; use ApiRootState instead. RootState is planned for removal in 3.0.
AnyAction remains available for compatibility but is deprecated in favor of UnknownAction.
createStore is visually marked deprecated to encourage migration to Redux Toolkit; it continues to work without runtime errors or warnings.
A non-deprecated export of the same function as createStore is available for projects that want to avoid the deprecation indicator.
New APIs and options 61
A typed thunk for query and infinite query endpoints returns the running request promise for a cache entry, or undefined, without adding a subscription.
A thunk returns read-only access to middleware-tracked state for that store, or undefined when the API middleware is absent.
A named public type improves editor hover readability.
Forked tasks can access getState, dispatch actions, and fork child tasks; nested forks are cancelled with their parent, and autoJoin makes the parent wait.
ForkedTaskAPI and task executor types accept optional State and DispatchType generics that flow through listener APIs and withTypes() variants.
The onCacheEntryAdded lifecycle API reports whether an entry was removed by resetApiState, another removal, or is still cached.
Query initiate() results expose an isSubscribed() method to check subscription status.
A new exported type represents numeric or cache-entry-function polling intervals.
A new exported type names the supported query start reasons.
Query initiate() accepts a retention duration in seconds; after the last subscriber leaves, the entry is kept for the greater of retainFor and keepUnusedDataFor.
Query APIs and lifecycle callbacks receive the reason a query is fetching; mutations receive undefined, and hydrate is reserved but not yet set.
ApiRootState is the replacement for RTK Query's RootState type.
Returns a Redux DevTools actionSanitizer that displays RTK Query actions with their endpoint name without modifying dispatched actions.
RTK declares and exports its own Draft type with the same shape as Immer's, so emitted declarations reference @reduxjs/toolkit rather than immer.
RTK declares and exports its own Patch type with the same shape as Immer's, so emitted declarations reference @reduxjs/toolkit rather than immer.
A new exported type describes a query cache entry for a definition.
removeMany accepts a { where } filter and removes entities whose fields match all supplied values using ===; an empty filter removes nothing.
A new exported generic type describes the removeMany filter.
api.util.selectAllQueryEntries(state) returns memoized cache entries for every endpoint.
getSelectors() now includes selectByIds(state, ids), returning existing entities in the order of ids and skipping missing ids.
api.util.selectEntriesForEndpoint(state, endpointName) returns memoized cache entries for one query or infinite query endpoint, including each queryCacheKey.
RTK Query fulfilled and rejected-with-value thunk metadata now includes a per-store sequence counter, allowing request ordering to be determined.
RTK Query fulfilled and rejected-with-value thunk metadata now includes startedTimeStamp, matching the request's pending action.
A new type describes the action that addListener actually dispatches.
A new type describes the action that removeListener actually dispatches.
This hook result type is now exported from @reduxjs/toolkit/query/react for wrapping hooks with a generic selectFromResult.
RTK declares and exports its own WritableDraft type with the same shape as Immer's.
The infinite query hook result type now includes the page error flags.
RTK Query hook options types are exported for reuse, so you no longer need to extract them with Parameters.
The RTK package now includes agent skill files for using and migrating to modern RTK, managing client and server state, and handling side effects.
Adds an option for infinite queries that, when false, refetches only the first cached page and shrinks the cache from N pages to 1.
Adds middleware to the dynamic middleware instance after store setup.
Provides async thunk creation for a customized createSlice.
Creates a customized createSlice with asyncThunk support when configured with asyncThunkCreator.
Combines slices or objects of slices into a reducer, using slice names as state keys, and supports runtime reducer injection and lazy-loaded slice types.
The creator callback syntax provides asyncThunk for declaring an async thunk inside createSlice.
The creator callback syntax provides preparedReducer for a case reducer with a prepare callback.
The creator callback syntax provides create.reducer for defining a normal case reducer.
Adds a settled matcher for async thunk actions.
A dynamic middleware API supports adding middleware at runtime.
Adds middleware to the store dynamically at runtime.
Adds an Id generic argument so item IDs are strongly typed, with inference from the entity id field or selectId return type.
Slices can define selectors directly; generated selectors assume the slice is mounted under slice.name, and getSelectors supports an alternate state location.
A creator callback syntax lets reducers define case reducers, prepared reducers, and async thunks inside createSlice.
This is now the primary build artifact, with a CJS artifact and a legacy ESM copy also published.
Accepts an options object as its second argument, allowing a preferred createSelector method to memoize generated selectors.
Generates slice selectors using an alternate state location when passed a selectSliceState function.
The reducer generated by combineSlices has an inject method for dynamically adding slices at runtime.
The new utility checks whether an unknown value is an action object.
Adds a cancel method to listenerApi.
Adds a method to throw if the listener has been cancelled.
Dynamic middleware includes a React hook integration that automatically adds middleware to the store and returns the updated dispatch method.
createSlice reducers can use a creator callback syntax to define case reducers, prepared reducers, and async thunks; the existing object syntax remains standard.
A browser ESM file is available for loading the package from a CDN such as Unpkg.
A second ESM build artifact is provided to support Webpack 4.
Adds a utility for selecting cached arguments for a query.
createSlice accepts selectors directly; generated selectors assume the slice is mounted under its name in the root state.
Adds a slice method for looking up the slice state at its default root-state location.
The basic Redux Thunk middleware is now available as a named export.
Customization through withExtraArgument is now available as a named export.
Generates TypeScript types for reducers that will be added later.
Performance 7
The Api type uses the core module type directly and ApiModules has variance annotations, reducing type instantiations and check time without runtime changes.
esbuild can now tree-shake createAsyncThunk when a bundle imports only createSlice, shrinking that bundle by about 1 kB (brotli).
Dispatch work is reduced in createAction.match, createReducer, listener middleware, and the RTK Query reducer, improving performance for actions those components do not need to handle.
RTK Query records subscription changes by cache key and writes one patch per changed key; non-subscribing requests no longer schedule a sync.
Composed middleware chains are cached when the middleware list has not changed.
Production builds extract error message strings, saving about 1000 bytes from production bundles.
Subscription status values are synced to Redux state less often to improve performance.
Behavior and default changes 17
Headers now accept number and boolean values, which are converted to strings.
The serializability check now ignores payload.options.pollingInterval by default; custom ignoredActionPaths should include it.
A refetch while a request is running joins that request instead of starting another; initiate() also joins a running upsertQueryData.
Polling interval may be a function of the current cache entry; the lowest interval among subscribers wins, and returning zero, a negative number or a non-number disables polling.
Polling skips while unfocused only when every polling subscriber sets this option; non-polling subscribers do not affect it.
RTK Query hooks warn in development when they render with a different store than the one they first subscribed to; key the Provider to remount when swapping stores.
Development builds now warn when updateCachedData is called before the entry has data, because the call does nothing.
Bad entries are skipped individually instead of failing the batch; unknown or mutation endpoint names and throwing providesTags callbacks are skipped with development warnings.
The sorted adapter merges multiple updates for the same ID before applying them.
Listener middleware matcher types now accept interface-based type guards as well as type-based definitions.
Sets the accept header based on the selected responseHandler, choosing JSON or text.
Stops retrying when the request's AbortSignal is aborted.
configureStore adds autoBatchEnhancer by default, delaying subscriber notifications for multiple low-priority actions and improving performance without manual store configuration.
Adds autoBatchEnhancer to the store setup by default so subscribers can benefit from improved performance without manual store configuration.
Custom contexts are typed as ReactReduxContextValue | null; hooks account for null by throwing an error without affecting their return type.
createSelector checks for common mistakes, including input selectors that return new references and result functions that immediately return their argument; checks can be customized at selector creation or globally.
Package definitions now use the exports field, with a modern ESM build as the primary artifact and CJS retained for compatibility.
Tooling 5
A named public type improves editor hover readability.
@types/react is now an optional peer dependency so TypeScript can find RTK's React entry-point types with isolated package-manager layouts.
Runs the codemod that converts a slice file to the reducer builder callback syntax.
The codemods package provides transforms for migrating object syntax to builder syntax.
Provides a codemod to convert an existing slice to the new reducer builder callback syntax.
Fixes and other changes 62
Wrapping createSlice in a generic helper now preserves the prepare callback's parameter types.
The entity adapter preserves ids order when an update changes an entity's id.
timeout now works when the request passes its own signal.
Each initiate() promise now resolves with its own request's result, captured when that request's fulfilled or rejected action reaches the store.
Invalidating an entry with a running request waits for that request to finish, then refetches subscribed entries or removes unsubscribed ones.
A hook with skip: true no longer throws on a store without the API middleware; a non-skipped hook still throws from initiate()'s check.
The raf fallback no longer throws a cancelAnimationFrame ReferenceError in test environments that delete window globals during teardown.
It only resolves for a response from a request started while that lifecycle was waiting, preventing discarded late responses from resolving a later lifecycle.
Listener middleware no longer leaves timers running after condition is cancelled or its action arrives first.
Listener middleware no longer leaves timers running after delay is cancelled or the action arrives first.
The dispatch result is now typed as void, matching runtime behavior.
The dispatch result is now typed as boolean, matching runtime behavior.
A null body no longer throws before the request is sent.
Explicit content-type headers are preserved for ArrayBuffer, typed array, and Blob bodies; they are still removed for FormData and JSON content types on non-JSON bodies, with a case-insensitive check.
In a mutation's onQueryStarted, getCacheEntry now finds the entry for fixedCacheKey mutations instead of returning uninitialized.
Removal timers are cleared when a key gets a subscriber or is removed, and cache hits from subscribe: false calls no longer push back removal indefinitely.
Query arguments containing NaN no longer cause an endless refetch loop when the query errors.
Synchronous throws are caught and logged with console.error.
Polling stops after the last unsubscribe, skips when a request is pending, stops when an entry is removed, and reschedules when a subscriber switches to a slower interval.
Values above 2^31-1 ms are clamped with a development warning to avoid setTimeout overflow.
Reset now clears the subscription sync timer and delayed tag invalidation state so previously scheduled work cannot run afterward.
An overlapping refetch stays registered as the running query, so later calls join it and aborting it works.
Circular references in state or actions are now reported as non-serializable values instead of overflowing the stack.
Focus and online events now work with more than one store.
A due poll now reads the current skipPollingIfUnfocused value instead of the value present when its timer was set.
Infinite-query page triggers and initiate no longer send requests when the query argument is skipToken.
Listener middleware no longer leaves timers running after take is cancelled or the action arrives first.
fetchBaseQuery clears its timeout timer when a request finishes and reports a timeout during response body reading as TIMEOUT_ERROR.
A failed upsert over an existing entry no longer leaves that entry stuck in pending.
Its internal state proxy cache is now scoped per instance, preventing multiple combined reducers from interfering with each other.
rejectedWithValue is now set correctly when rejectWithValue is called with a falsy payload.
setAll keeps the last item when given duplicate IDs, matching setMany.
A URL is treated as absolute only when it starts with a scheme.
The middleware now handles circular references in state.
Fetching past the end of an infinite query list no longer triggers onQueryStarted.
Lazy query hooks now re-subscribe when effects restart while hook state is preserved, such as with Fast Refresh or Activity.
Polling checks current cache state when each poll fires, so focus loss after scheduling is respected and polling stops if the cache entry was removed.
Rehydrating state no longer errors when an endpoint name has no definition.
Tags with falsy IDs, such as 0, now invalidate and clean up correctly.
Queued tag invalidations are no longer run too early and lost when a duplicate query request is rejected by the thunk condition.
RTK now supports TypeScript 7.0 and 7.1. The tested support matrix is TypeScript 5.6+.
data now reflects updateQueryData cache changes made while a refetch is in flight.
isSuccess now stays false during an unrelated re-render while a query is refetching after an error.
The enhancer's requestAnimationFrame timer now has a 100ms timeout fallback so updates flush when rAF does not work in background tabs or opened windows.
The isSuccess status flag stays true when switching infinite query cache entries, preventing accidental UI flashes.
AbortSignal handling falls back to a plain Error when DOMException is unavailable, including in React Native environments.
The type now correctly includes the fetchNextPage and fetchPreviousPage fields.
Reworked AbortController handling to avoid an error in a rare case involving resetApiState and retry().
Fixes the immutability development middleware so regex values in ignoredPaths are tested as regexes rather than treated as strings.
Fixes an issue where byte-shaving work in 2.10 caused window access to break in SSR.
Improves type inference when PreloadedState might not match the incoming type, such as with persisted values.
Fixes the calculation of whether a request is active when checking for cache entry cleanup.
Does not set the content-type header for non-JSONifiable request bodies such as FormData, allowing the browser to set it.
Returns unknown errors as {error} instead of rethrowing them, as a base query is supposed to.
Respects maxRetries when retrying after unknown errors, as it already did for known errors.
Internal subscription data is per-store again, preventing subscription IDs from appearing across SSR requests.
Initiates requests without adding a subscription, so cache entries remain only for the keepUnusedDataFor period unless the app subscribes.
Sorted entity adapters now keep the first occurrence when addMany receives duplicate IDs.
RTK Query types ensure data is non-undefined when isSuccess is true, including with exactOptionalPropertyTypes.
clearListeners can cancel effects that have become unsubscribed.
Sorted entity adapters now keep only unique IDs in state.ids when setMany receives duplicate IDs.
RTK Query now always tracks cache entries and removes them as needed, addressing issues with unsubscribed initiations and lazy-query promise resolution.