Angular bindings for Redux
npm install @angular-redux/store@angular-redux/store@^9 is what you need. This consumes breaking changes from RxJS and Angular 6, as well as updated typedefs from Redux 4.
Use @angular-redux/store@^7 - this version supports Angular 5, and also changes to using lettable operators.
Use @angular-redux/store@^6 - This supports Angular 4 and earlier.
@angular-redux/store@6?Where possible, I will be maintaining and applying any fixes / enhancements for v7 into v6 where it does not introduce a breaking change.
I made a few mistakes trying to publish fixes / etc to two major versions, which caused some releases to get tagged incorrectly and caused some confusion. Sorry for any confusion this has caused, and will do better on avoiding this in the future, and being more transparent with the releases that are going out.
Angular bindings for Redux.
For Angular 1 see ng-redux




Redux is a popular approach to managing state in applications. It emphasises:
- A single, immutable data store.
- One-way data flow.
- An approach to change based on pure functions and a stream of actions.
You can find lots of excellent documentation here: Redux.
We provide a set of npm packages that help you integrate your redux store
into your Angular 2+ applications. Our approach helps you by bridging the gap
with some of Angular's advanced features, including:
- Change processing with RxJS observables.
- Compile time optimizations with NgModule and Ahead-of-Time compilation.
- Integration with the Angular change detector.
- I already know what Redux and RxJS are. Give me the TL;DR.
- I'm just learning about Redux. Break it down for me!
- Talk is cheap. Show me a complete code example.
- Take me to the API docs.
@angular-redux/store has a peer dependency on redux, so we need to install it as well.
``sh`
npm install --save redux @angular-redux/store
`typescript
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './containers/app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
`
Import the NgReduxModule class and add it to your application module as animport. Once you've done this, you'll be able to inject NgRedux into your
Angular components. In your top-level app module, you
can configure your Redux store with reducers, initial state,
and optionally middlewares and enhancers as you would in Redux directly.
`typescript
import { NgReduxModule, NgRedux } from '@angular-redux/store';
import { createLogger } from 'redux-logger';
import { rootReducer } from './reducers';
interface IAppState {
/ ... /
}
@NgModule({
/ ... /
imports: [, / ... / NgReduxModule],
})
export class AppModule {
constructor(ngRedux: NgRedux
ngRedux.configureStore(rootReducer, {}, [createLogger()]);
}
}
`
Or if you prefer to create the Redux store yourself you can do that and use the
provideStore() function instead:
`typescript
import {
applyMiddleware,
Store,
combineReducers,
compose,
createStore,
} from 'redux';
import { NgReduxModule, NgRedux } from '@angular-redux/store';
import { createLogger } from 'redux-logger';
import { rootReducer } from './reducers';
interface IAppState {
/ ... /
}
export const store: Store
rootReducer,
applyMiddleware(createLogger()),
);
@NgModule({
/ ... /
imports: [, / ... / NgReduxModule],
})
class AppModule {
constructor(ngRedux: NgRedux
ngRedux.provideStore(store);
}
}
`
> Note that we're also using a Redux middleware from the community here:
> redux-logger. This is just to show
> off that @angular-redux/store is indeed compatible with Redux middlewares as younpm install --save redux-logger
> might expect.
>
> Note that to use it, you'll need to install it with npm install --save-dev @types/redux-logger
> and type definitions for it with .
Now your Angular app has been reduxified! Use the @select decorator to.dispatch()
access your store state, and to dispatch actions:
`typescript
import { select } from '@angular-redux/store';
@Component({
template:
'',
})
class App {
@select() count$: Observable
constructor(private ngRedux: NgRedux
onClick() {
this.ngRedux.dispatch({ type: INCREMENT });
}
}
`
Here are some examples of the angular-redux family of packages in action:
- Zoo Animals Combined Example App
- Reduxify your Routing with @angular-redux/router
- Reduxify your Forms with @angular-redux/form
- Using Redux with Angular - JS Toronto Meetup 2016-07-12
- Getting started with Redux
- Awesome Redux: Community Resources
@angular-redux/store uses an approach to redux based on RxJS Observables to select and transformreselect
data on its way out of the store and into your UI or side-effect handlers. Observables
are an efficient analogue to for the RxJS-heavy Angular world.
Read more here: Select Pattern
We also have a number of 'cookbooks' for specific Angular topics:
- Using Angular's Dependency Injector with Action Creators
- Using Angular's Dependency Injector with Middlewares
- Managing Side-Effects with redux-observable Epics
- Using the Redux DevTools Chrome Extension
- @angular-redux/store and ImmutableJS
- Strongly Typed Reducers
Want to hack on angular-redux/store or any of the related packages? Feel free to do so, but please test your changes before making any PRs.
Here's how to do that:
1. Write unit tests. You can check that they work by running
npm test.npm run lint
2. Run the linter. If your editor doesn't do it automatically, do it
manually with .
3. Test your changes in a 'real world scenario'. We use the example-app for this, using some npm
fakery to 'publish the package locally':
- clone the example app (git clone https://github.com/angular-redux/example-app.git)cd
- generate a 'local package' ( to your angular-redux/store clone and run npm pack). This will create a .tgz file.cd
- hook your 'local package' up to your example-app ( to your example-app clone and run npm install --save /path/to/the/tgz/file/from/above)ng serve --aot`
- run
Please make sure your changes pass Angular's AoT compiler, because it's a bit finicky with TS syntax.