configureStore is the Redux Toolkit 3,824 replacement for createStore: it takes a named options object, calls combineReducers, applyMiddleware and compose for you, wires up the DevTools, and installs middleware that catches common mistakes.
import { configureStore } from '@reduxjs/toolkit';
import cartReducer from '../features/cart/cartSlice';
import filtersReducer from '../features/filters/filtersSlice';
export const store = configureStore({
reducer: { cart: cartReducer, filters: filtersReducer },
preloadedState: JSON.parse(sessionStorage.getItem('cart') || 'null') ?? undefined,
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({ thunk: { extraArgument: apiClient } }).concat(analytics),
devTools: process.env.NODE_ENV !== 'production',
});getDefaultMiddleware() installs redux-thunk in every build, plus three development-only checks: state mutated in or between dispatches, non-serializable values such as dates and promises in state or actions, and dispatch(increment) written without the call. The first two walk the whole state tree on every dispatch, which is why production strips them; on a large store, narrow them with immutableCheck: { ignoredPaths: [...] } or serializableCheck: { ignoredActions: [...] } rather than turning them off. The middleware option replaces the default list, so always take the callback form: .concat(x) puts x after the defaults and .prepend(x) before them, both preserving the types that make dispatch know about your thunks.