NgRx • Debugging • Redux DevTools
NgRx Store DevTools is a powerful debugging companion that lets you inspect actions, visualize state changes, and even time-travel through your application’s state history using the Redux DevTools browser extension.
NgRx Store DevTools hooks your NgRx store into the Redux DevTools extension so you can:
instrument() – configures how DevTools records and displays state.maxAge – how many past states are kept in history.logOnly – allows read-only DevTools in production (no time-travel or dispatch).environment.production to toggle features safely.To use NgRx Store DevTools you need:
@ngrx/store-devtools package installed in your project.StoreDevtoolsModule.instrument() in your AppModule.The core idea is to wrap your root store with DevTools instrumentation so every action and state transition is mirrored into the DevTools UI.
The following example shows how to install and configure NgRx Store DevTools in your Angular application:
// Install the DevTools package in your Angular project
npm install @ngrx/store-devtools --save
// app.module.ts – configure NgRx Store DevTools
import { NgModule } from '@angular/core';
import { StoreModule } from '@ngrx/store';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { environment } from '../environments/environment';
import { reducers } from './reducers';
@NgModule({
imports: [
StoreModule.forRoot(reducers),
StoreDevtoolsModule.instrument({
maxAge: 25, // Retain the last 25 states for time-travel debugging
logOnly: environment.production // In production, allow read-only logging only
})
]
})
export class AppModule {}
[Todos] Add Todo), it appears in the DevTools timeline with its payload.maxAge (e.g., 25–50) to balance memory usage with debugging depth.logOnly: environment.production to avoid exposing sensitive data or allowing action replay.[Auth] Login Success) so the DevTools timeline reads like a story of user interactions.maxAge from 25 to 5 and note how the history length affects time-travel.logOnly and rebuild for production mode to see how the DevTools capabilities change.