
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
ngrx-store-ionic-storage
Advanced tools
Simple storage syncing between @ngrx/store and @ionic/storage.
Simple syncing between @ngrx 7 and Ionic Storage.
If you are looking to use this package with an Ionic 2 or 3 app, please use version 4 of this package.
This library depends on the store and effects modules from @ngrx/platform and Ionic 4.
Make sure you have a scaffolded Ionic 4 app. This library supports Ionic version 4 and above. For more details, see the Ionic documentation.
Then run:
npm install @ngrx/store @ngrx/effects @ionic/storage ngrx-store-ionic-storage
Next, make sure you have installed the cordova-sqlite-storage plugin. This allows Ionic Storage to use the most optimal storage mechanism available, depending on the target device.
ionic cordova plugin add cordova-sqlite-storage
StorageSyncEffects and run it through the EffectsModule.storageSync function to create a meta-reducer, and compose it with your other reducers.Here is an example with two app-specific reducers, books and collection, and a state object appState.
import { NgModule } from '@angular/core';
import { StoreModule, ActionReducerMaps, ActionReducer, MetaReducer } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { StorageSyncEffects, storageSync } from 'ngrx-store-ionic-storage';
import { BookActions, CollectionActions } from './actions';
import { booksReducer, collectionReducer } from './reducers';
import { appState } from './app-state'
export function onSyncError(err) {
console.log(err);
}
export const reducers: ActionReducerMap<appState> = {
books: booksReducer,
collection: collectionReducer
};
export const storageSyncReducer = storageSync({
keys: ['collection'], // Only sync the `collection` state
ignoreActions: [ // Don't sync when these actions occur
BookActions.SELECT,
CollectionActions.FILTER,
],
hydratedStateKey: 'hydrated', // Add this key to the state
onSyncError: onSyncError // If a sync fails
});
export function storageMetaReducer(reducer: ActionReducer<any>): ActionReducer<any, any> {
return storageSyncReducer(reducer);
}
export const metaReducers: MetaReducer<any, any>[] = [storageMetaReducer];
@NgModule({
imports: [
StoreModule.forRoot(reducers, {
metaReducers,
initialState: {
hydrated: false
}
})
EffectsModule.forRoot([ StorageSyncEffects ])
]
})
export class MyAppModule {}
keys: specify the portion of your state to sync to the underlying storage mechanism.ignoreActions: don't sync whenever any of these actions are fired.hydratedStateKey: if present, the sync reducer will add a flag to your app state when the initial hydration has completed. You can bind an observable to this flag, and so be notified when the app has been hydrated.onSyncError: a callback, called whenever there was an error syncing the state. The callback is passed a single err parameter.hydrated.reducer.ts
import { Action } from '@ngrx/store';
export interface HydratedState {}
export function reducer(state: boolean = false, action: Action): State {
return state;
};
main.reducer.ts
import { ActionReducerMap } from '@ngrx/store';
import * as fromHydrated from './hydrated.reducer';
export interface State {
hydrated: fromHydrated.State
//...
}
export const reducer: ActionReducerMap<State> = {
hydrated: fromHydrated.reducer
//...
};
The sync reducer is a meta-reducer. On startup, it hydrates the initial state from the underlying storage mechanism. Then, whenever an action is dispatched to the store, the sync reducer saves the portion of state to the underlying storage mechanism, after all other reducers have run.
The sync reducer will only store the portion of state provided in the keys option, and will not run for any actions that are specified in the ignoreActions option.
Much of this library is based on ngrx-store-localstorage. While this is an excellent choice for desktop web browsers, for Ionic apps a better solution exists for local storage: Ionic Storage. This provides a more robust storage mechanism, depending on the device where the app is running. Since Ionic Storage is asynchronous, the functionality needed to be written from the ground-up to support an async get/set operation.
MIT
FAQs
Simple storage syncing between @ngrx/store and @ionic/storage.
We found that ngrx-store-ionic-storage demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.