by brandonroberts

brandonroberts / ngrx-store-freeze

@ngrx/store meta reducer that prevents state from being mutated.

199 Stars 13 Forks Last release: Not found MIT License 40 Commits 6 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:


npm version CircleCI

ngrx-store-freeze is a meta-reducer that prevents state from being mutated

  • Recursively freezes the current state, the dispatched action payload if provided and the new state.
  • When mutation occurs, an exception will be thrown.
  • Should be used only in development to ensure that the state remains immutable.


npm i --save-dev ngrx-store-freeze


yarn add ngrx-store-freeze --dev


import { StoreModule, MetaReducer, ActionReducerMap } from '@ngrx/store';
import { storeFreeze } from 'ngrx-store-freeze';
import { environment } from '../environments/environment'; // Angular CLI environment

export interface State { // reducer interfaces }

export const reducers: ActionReducerMap = { // reducers }

export const metaReducers: MetaReducer[] = !environment.production ? [storeFreeze]: [];

@NgModule({ imports: [ StoreModule.forRoot(reducers, { metaReducers }), ] }) export class AppModule {}

Additional Documentation


redux-freeze - Redux middleware that prevents state from being mutated
Attila Egyed - The original maintainer of this project

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.