Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including ngrx-store-freeze with all npm packages installed. Try it out:

require("@ngrx/store/package.json"); // @ngrx/store is a peer dependency. var ngrxStoreFreeze = require("ngrx-store-freeze")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

ngrx-store-freeze v0.2.4

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


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<State> = {
  // reducers

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

  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

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free