Redux Toolkit configureStore middleware ordering when using a plain array
26K reputation · 05 Dec 2021, 04:58 UTC
When using configureStore, developers can supply middleware as either a plain array or a callback that receives getDefaultMiddleware. The documentation notes that passing a plain array does not guarantee the relative order of custom middleware versus the default middleware chain (serializableCheck, immutableCheck, thunk). This creates uncertainty for middleware that depends on side‑effects from those defaults.
Because the default middleware order is not exposed as a public constant and may change between releases, code that assumes a specific sequence can break silently. The lack of a built‑in option to force custom middleware to run before or after the defaults leaves the ordering decision to the user, which remains an unresolved design question.
Does Redux Toolkit provide a way to enforce that custom middleware always executes after the default middleware without using the functional callback? If not, what pattern should be considered a reliable alternative for guaranteeing order?