🧠 React State Management
Estimated reading: 4 minutes 191 views

React Redux Toolkit – Simplified Redux for Modern State Management (2025 Guide)


Introduction – Why Redux Toolkit?

Redux is a powerful but often boilerplate-heavy state management library. To simplify setup and improve productivity, the Redux team introduced the Redux Toolkit (RTK)β€”now the standard way to write Redux logic in 2025.

Redux Toolkit streamlines the Redux process by:

  • Eliminating boilerplate code
  • Enabling mutation-style logic with Immer
  • Providing built-in support for async actions
  • Encouraging modular, slice-based architecture

In this guide, you’ll learn:

  • How Redux Toolkit simplifies actions, reducers, and store
  • The core API (createSlice, configureStore, createAsyncThunk)
  • Real-world examples and usage patterns
  • Best practices for scalable Redux applications

What Is Redux Toolkit?

Redux Toolkit is the official, recommended way to write Redux logic. It wraps Redux APIs with simplified utilities like:

UtilityPurpose
configureStore()Simplified store setup with DevTools
createSlice()Creates reducer + actions in one step
createAsyncThunk()Handles async actions (API calls)
createEntityAdapter()Normalize and manage collections

1. Installing Redux Toolkit

npm install @reduxjs/toolkit react-redux

2. Create a Slice with createSlice

A slice contains:

  • A name
  • Initial state
  • Reducer functions
  • Auto-generated action creators

counterSlice.js

import { createSlice } from '@reduxjs/toolkit';

const counterSlice = createSlice({
  name: 'counter',
  initialState: { value: 0 },
  reducers: {
    increment: (state) => {
      state.value++; //  safe mutation via Immer
    },
    decrement: (state) => {
      state.value--;
    },
    reset: (state) => {
      state.value = 0;
    },
  },
});

export const { increment, decrement, reset } = counterSlice.actions;
export default counterSlice.reducer;

3. Configure Store with configureStore

store.js

import { configureStore } from '@reduxjs/toolkit';
import counterReducer from './counterSlice';

export const store = configureStore({
  reducer: {
    counter: counterReducer,
  },
});

Automatically sets up Redux DevTools + middleware


4. Use Redux in React Components

Wrap App with Provider

import { Provider } from 'react-redux';
import { store } from './store';

<Provider store={store}>
  <App />
</Provider>

Access State with useSelector

import { useSelector } from 'react-redux';

const count = useSelector((state) => state.counter.value);

Dispatch Actions with useDispatch

import { useDispatch } from 'react-redux';
import { increment } from './counterSlice';

const dispatch = useDispatch();
<button onClick={() => dispatch(increment())}>+</button>;

5. Handling Async Logic with createAsyncThunk

import { createAsyncThunk } from '@reduxjs/toolkit';

export const fetchUser = createAsyncThunk('user/fetchUser', async (id) => {
  const res = await fetch(`/api/user/${id}`);
  return await res.json();
});

Use with extraReducers:

const userSlice = createSlice({
  name: 'user',
  initialState: { loading: false, data: null },
  reducers: {},
  extraReducers: (builder) => {
    builder
      .addCase(fetchUser.pending, (state) => {
        state.loading = true;
      })
      .addCase(fetchUser.fulfilled, (state, action) => {
        state.loading = false;
        state.data = action.payload;
      });
  },
});

Clean async handling
Works great with loaders, error states


Redux Toolkit vs Classic Redux

FeatureClassic ReduxRedux Toolkit
Store SetupManualconfigureStore() with DevTools
ActionsManually definedAuto-generated with createSlice()
ReducersHandwritten switchDeclarative and scoped
AsyncRedux Thunk or SagascreateAsyncThunk built-in
ImmutabilityManualBuilt-in with Immer
BoilerplateHighMinimal

Best Practices

Use one slice per feature/domain
Name slices and actions consistently
Use createAsyncThunk for all async logic
Use selectors to isolate state access
Avoid putting local UI state in Redux unless needed globally


Summary – Recap & Next Steps

Redux Toolkit offers a modern, clean, and scalable approach to global state management in React. It simplifies the traditional Redux workflow while retaining its power.

Key Takeaways:

  • Use createSlice() to define state + reducers + actions
  • Use configureStore() for fast setup with DevTools
  • Use createAsyncThunk() for API calls and loading states
  • Reduces boilerplate and improves readability
  • Recommended by the Redux team as the standard in 2025

Real-World Relevance:
Used in apps like Notion, GitHub Projects, and enterprise dashboards to manage complex UI and data state in a scalable way.


FAQ Section

Is Redux Toolkit a replacement for Redux?
It’s built on top of Redux and is now the official recommended way to use it.


Can I still use regular Redux with Toolkit?
Yes. Toolkit is compatible with classic Redux but removes the need for manual setup.


What makes Redux Toolkit better?
Built-in DevTools, simplified slices, Immer-based reducers, async helpers, and less boilerplate.


Should I use Toolkit for small apps?
Yes! Redux Toolkit is simple enough for small apps and powerful enough for large ones.


Is createAsyncThunk better than redux-thunk?
It’s more structured, typed, and easier to maintain in larger applications.


Share Now :
Share

πŸ› οΈ React Redux Toolkit – Simplified Redux

Or Copy Link

CONTENTS
Scroll to Top