@reduxjs/toolkit

The official, opinionated Redux toolset — cuts the boilerplate and bakes in best practices.

@reduxjs/toolkit

React

The official, opinionated Redux toolset — cuts the boilerplate and bakes in best practices.

Fit

Bundle (gzip)

13.6 kB

37.0 kB raw

Install size includes transitive dependencies. Bundle size is gzipped browser payload.

Freshness

The Problem

Classic Redux earned a reputation for ceremony: action type constants, hand-written immutable reducers, thunk setup, and a pile of files just to update one value. Teams spent more time on plumbing than on features.

What It Does

Redux Toolkit is the batteries-included way to write Redux. configureStore sets up the store with sensible defaults, and createSlice generates actions and reducers together while letting you write "mutating" logic that Immer converts to safe immutable updates. RTK Query adds a full data-fetching and caching layer on top.

Installation

bash
npm install @reduxjs/toolkit react-redux

Usage Example

js
import { createSlice, configureStore } from '@reduxjs/toolkit';

const counter = createSlice({
  name: 'counter',
  initialState: { value: 0 },
  reducers: {
    increment: (state) => { state.value += 1; },
    addBy: (state, action) => { state.value += action.payload; },
  },
});

export const { increment, addBy } = counter.actions;
export const store = configureStore({ reducer: { counter: counter.reducer } });

Related packages