Gathering detailed insights and metrics for redux
Gathering detailed insights and metrics for redux
Gathering detailed insights and metrics for redux
Gathering detailed insights and metrics for redux
A JS library for predictable global state management
npm install redux
Typescript
Module System
Node Version
NPM Version
98.8
Supply Chain
100
Quality
82.8
Maintenance
100
Vulnerability
100
License
Updated on 06 Dec 2024
Minified
Minified + Gzipped
TypeScript (82.03%)
JavaScript (13.89%)
CSS (4.07%)
Cumulative downloads
Total Downloads
Last day
25.5%
Compared to previous day
Last week
-1.9%
Compared to previous week
Last month
3.6%
Compared to previous month
Last year
11%
Compared to previous year
20
Redux is a predictable state container for JavaScript apps.
It helps you write applications that behave consistently, run in different environments (client, server, and native), and are easy to test. On top of that, it provides a great developer experience, such as live code editing combined with a time traveling debugger.
You can use Redux together with React, or with any other view library. The Redux core is tiny (2kB, including dependencies), and has a rich ecosystem of addons.
Redux Toolkit is our official recommended approach for writing Redux logic. It wraps around the Redux core, and contains packages and functions that we think are essential for building a Redux app. Redux Toolkit builds in our suggested best practices, simplifies most Redux tasks, prevents common mistakes, and makes it easier to write Redux applications.
The recommended way to start new apps with React and Redux Toolkit is by using our official Redux Toolkit + TS template for Vite, or by creating a new Next.js project using Next's with-redux
template.
Both of these already have Redux Toolkit and React-Redux configured appropriately for that build tool, and come with a small example app that demonstrates how to use several of Redux Toolkit's features.
1# Vite with our Redux+TS template 2# (using the `degit` tool to clone and extract the template) 3npx degit reduxjs/redux-templates/packages/vite-template-redux my-app 4 5# Next.js using the `with-redux` template 6npx create-next-app --example with-redux my-app
We do not currently have official React Native templates, but recommend these templates for standard React Native and for Expo:
npm install @reduxjs/toolkit react-redux
For the Redux core library by itself:
npm install redux
For more details, see the Installation docs page.
The Redux core docs are located at https://redux.js.org, and include the full Redux tutorials, as well usage guides on general Redux patterns:
The Redux Toolkit docs are available at https://redux-toolkit.js.org, including API references and usage guides for all of the APIs included in Redux Toolkit.
The Redux Essentials tutorial is a "top-down" tutorial that teaches "how to use Redux the right way", using our latest recommended APIs and best practices. We recommend starting there.
The Redux Fundamentals tutorial is a "bottom-up" tutorial that teaches "how Redux works" from first principles and without any abstractions, and why standard Redux usage patterns exist.
The #redux channel of the Reactiflux Discord community is our official resource for all questions related to learning and using Redux. Reactiflux is a great place to hang out, ask questions, and learn - please come and join us there!
Redux is a valuable tool for organizing your state, but you should also consider whether it's appropriate for your situation. Please don't use Redux just because someone said you should - instead, please take some time to understand the potential benefits and tradeoffs of using it.
Here are some suggestions on when it makes sense to use Redux:
Yes, these guidelines are subjective and vague, but this is for a good reason. The point at which you should integrate Redux into your application is different for every user and different for every application.
For more thoughts on how Redux is meant to be used, please see:
The whole global state of your app is stored in an object tree inside a single store. The only way to change the state tree is to create an action, an object describing what happened, and dispatch it to the store. To specify how state gets updated in response to an action, you write pure reducer functions that calculate a new state based on the old state and the action.
Redux Toolkit simplifies the process of writing Redux logic and setting up the store. With Redux Toolkit, the basic app logic looks like:
1import { createSlice, configureStore } from '@reduxjs/toolkit' 2 3const counterSlice = createSlice({ 4 name: 'counter', 5 initialState: { 6 value: 0 7 }, 8 reducers: { 9 incremented: state => { 10 // Redux Toolkit allows us to write "mutating" logic in reducers. It 11 // doesn't actually mutate the state because it uses the Immer library, 12 // which detects changes to a "draft state" and produces a brand new 13 // immutable state based off those changes 14 state.value += 1 15 }, 16 decremented: state => { 17 state.value -= 1 18 } 19 } 20}) 21 22export const { incremented, decremented } = counterSlice.actions 23 24const store = configureStore({ 25 reducer: counterSlice.reducer 26}) 27 28// Can still subscribe to the store 29store.subscribe(() => console.log(store.getState())) 30 31// Still pass action objects to `dispatch`, but they're created for us 32store.dispatch(incremented()) 33// {value: 1} 34store.dispatch(incremented()) 35// {value: 2} 36store.dispatch(decremented()) 37// {value: 1}
Redux Toolkit allows us to write shorter logic that's easier to read, while still following the original core Redux behavior and data flow.
You can find the official logo on GitHub.
This project adheres to Semantic Versioning. Every release, along with the migration instructions, is documented on the GitHub Releases page.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
19 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
project is fuzzed
Details
Reason
packaging workflow detected
Details
Reason
Found 16/21 approved changesets -- score normalized to 7
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
91 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More