My question is which should I use? Can Redux Toolkit replace Redux core?
-
4Toolkit ***is*** Redux, its just an opinionated way of using it. It uses the library. – zero298 Dec 25 '21 at 05:53
-
FWIW there are plenty of other great state management libs (e.g. [effector](https://effector.dev/), [recoil](https://recoiljs.org/)) – jsejcksn Dec 25 '21 at 07:31
-
yes, I only know recoil and mobx – LXT Dec 26 '21 at 03:37
2 Answers
Redux used to be great but if you have tried none of them, I would highly recommend using Redux-Toolkit. The only case where I may want you to stick to redux is when you're using class-based components, where Redux Toolkit does have some boilerplate (like Redux) and you may miss out decent support.
However with functional components, Redux toolkit is like Redux on steroids.
Reason for using Redux toolkit:
A lot lesser boilerplate code is required compared to Redux.
Redux hooks like
useSelector
anduseDispatch
make things so short and easy to use. [This is not specific to Redux toolkit, however, highlighting it here as it is extremely helpful to consume these hooks in functional component and might be helpful for those who are completely new to redux]You don't need to do manual
thunk
setup as redux-toolkit comes with out of the boxcreateAsyncThunk
which enables you to perform async operations in very hassle free way.getState
is also very helpful in obtaining state variables across any of your actions or async operations.Mutability might be considered as advantage or disadvantage, but if you're not too used to writing with spread operators, you might love this feature as well. Do straight assignments and let redux toolkit take care of mutability under the hoods.
current
can be used to log your state anywhere in case you want to debug and understand where things are going wrong. (Of course, Redux debugger tools are great as well)Prebuilt templates: you might want to use
npx create-react-app my-app --template redux-typescript
or if you're using it with next:yarn create next-app --example with-redux with-redux-app
. It gives you a setup readyredux toolkit
boiler plate and also contains a boiler plate of most important redux state management applications so that you could refer them to create your own slices very easily.
I have been using a lot of redux and initially it was a bit confusing but once you get a good command over redux toolkit and if you're using a lot of functional components, you probably would never go back to redux again.

- 44,755
- 7
- 76
- 106

- 4,055
- 3
- 31
- 62
-
9For reason #2, useSelector and useDispatch are available without the toolkit as well. – Hyetigran Dec 25 '21 at 06:35
-
13One correction: Redux Toolkit has nothing to do with `useSelector`, `useDispatch` or `connect`. There is no difference between using Redux or Redux Toolkit in regards to React. That is the separate `react-redux` package you have to use in both cases. The difference between the two is the amount and safety of non-React-related code. – phry Dec 25 '21 at 09:48
-
thanks, @phry and hyetigran for the correction. My sole purpose was just to highlight it as the asker of the question was new to redux so just wanted to highlight it. – Shivam Sahil Dec 25 '21 at 10:37
Redux Toolkit is the official recommendation for all Redux code you write since 2019. See the Redux Style guide on this and Why Redux Toolkit is How To Use Redux Today.
I would recommend you start learning Redux by following the official Redux "Essentials" tutorial from the Redux homepage - and that will teach you Redux Toolkit from the beginning.

- 35,762
- 5
- 67
- 81