Synchronizes Angular state managed by @ngrx/store with browser's localStorage or sessionStorage. Version 20.1.0 supports Angular 20+ and @ngrx/store 20+. It provides a configurable meta-reducer that automatically persists specified state slices on every dispatch and rehydrates on app load. Differentiators include partial key sync, custom serialization/deserialization, encryption support, and optional storage change detection. Maintenance is active via semantic-release and CI (CircleCI).
npm install ngrx-store-localstorageNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Shows how to create a localStorageSync meta-reducer and include it in StoreModule.forRoot to persist a specific reducer key ('todos') to localStorage.
Upgrade Angular and @ngrx/store to version 20 or later.
Replace storageKeySerializer with key-specific configuration using serialize/deserialize functions.
Use partial key sync or define serialize/deserialize functions to handle non-serializable values.
Implement a custom reviver function to validate and migrate data during deserialization.
Ensure @angular/common is installed. Typically it's included with Angular projects.
Run `npm install ngrx-store-localstorage --save` and ensure the import path is exactly 'ngrx-store-localstorage'.
Change import to: `import { localStorageSync } from 'ngrx-store-localstorage'`Add `StoreModule.forRoot(reducers, { metaReducers })` to the imports array of your NgModule.Clear localStorage manually: `localStorage.removeItem('your-key')` or implement a try-catch in the reviver.