What is Redux Toolkit (RTK)?

Learn what really is the Redux toolkit. How would you describe its essence?

We'll cover the following

Before we discuss the use of RTK, it’s only fair to start off by defining the Redux toolkit and establishing what it can do.

Redux and toolkit

Let’s break the library’s moniker apart, i.e., Redux toolkit. That’s a decent place to start.

We have the words “Redux” and “toolkit.” Redux is an open-source JavaScript library for managing the application state. A toolkit is a set of tools that each helps us fix certain problems.

When you bring both words together, it gives you a clue of what RTK really is. That is, a toolbox for handling common Redux use cases.

While tools like screwdrivers and hammers do good in the real world, they aren’t quite useful with software. Except, when you want to smash your monitor with a hammer. Certainly, be my guest.

If Redux toolkit isn’t issuing out hammers and screwdrivers, then what does the toolbox comprise of? Take a guess.

The core of Redux Toolkit

If you said “utilities,” you’re right. Think of utility functions exported from the library where these functions exist to make Redux development a lot more fun. And it’s less boilerplate-like, so you can really focus on being efficient in writing code. This is the entire premise of the Redux toolkit.

While the above statements describe the absolute core of RTK, there’s one more thing to note.

When someone hands you a tool to do a job, in a sense, they’ve restricted your options. If I handed you a screwdriver to perform an experiment, I’m indirectly saying to you that this tool solves the problem. Just use it! But how you use it is up to you.

Basically, when you’re told that the Redux toolkit is the tool of choice for modern Redux development, a “tool” has been handed to you. Under the hood, they’ve also made numerous opinionated decisions on how the tool works because utility functions work in a certain way.

This leads to RTK being opinionated. Out-of-the-box, it makes choices for the Redux store setup and includes many Redux add-ons. I’ll point out many of these defaults, so you understand them. If you become uncomfortable with any of the defaults in your Redux development at any time, you’d be able to make the needed changes.

Finally, tools exist to solve certain problems. With the Redux toolkit, it helps simplify common use cases, such as setting up the Redux store, creating reducers, and handling immutable logic within your reducers.