The official, opinionated, batteries-included toolset for efficient Redux development
(Formerly known as "Redux Starter Kit")
The recommended way to start new apps with React and Redux Toolkit is by using the official Redux+JS template for Create React App, which takes advantage of React Redux's integration with React components.
npx create-react-app my-app --template redux
Or if you are a TypeScript user, use cra-template-redux-typescript, which is based on that template
npx create-react-app my-app --template redux-typescript
Redux Toolkit is available as a package on NPM for use with a module bundler or in a Node application:
# NPM
npm install @reduxjs/toolkit
# Yarn
yarn add @reduxjs/toolkit
It is also available as a precompiled UMD package that defines a window.RTK
global variable.
The UMD package can be used as a <script>
tag directly.
The Redux Toolkit package is intended to be the standard way to write Redux logic. It was originally created to help address three common concerns about Redux:
- "Configuring a Redux store is too complicated"
- "I have to add a lot of packages to get Redux to do anything useful"
- "Redux requires too much boilerplate code"
We can't solve every use case, but in the spirit of create-react-app
and apollo-boost
, we can try to provide some tools that abstract over the setup process and handle the most common use cases, as well as include some useful utilities that will let the user simplify their application code.
Because of that, this package is deliberately limited in scope. It does not address concepts like "reusable encapsulated Redux modules", folder or file structures, managing entity relationships in the store, and so on.
Redux Toolkit also includes a powerful data fetching and caching capability that we've dubbed "RTK Query". It's included in the package as a separate set of entry points. It's optional, but can eliminate the need to hand-write data fetching logic yourself.
Redux Toolkit includes these APIs:
configureStore()
: wrapscreateStore
to provide simplified configuration options and good defaults. It can automatically combine your slice reducers, adds whatever Redux middleware you supply, includesredux-thunk
by default, and enables use of the Redux DevTools Extension.createReducer()
: that lets you supply a lookup table of action types to case r