> For the complete documentation index, see [llms.txt](https://vytautas.gitbook.io/ng-state/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://vytautas.gitbook.io/ng-state/core-concepts/store/persist-state-plugin/configuring-custom-storage.md).

# Configuring custom storage

By default `localStorage` is used. However you can define other storages in one of two ways:

* Setting it globally by calling `PersistStateManager.configureStorage({...})` - passed object should contain `clear`, `getItem`, `removeItem`, `setItem` methods and method to gather keys from storage `() => Object.keys(sessionStorage)`

```typescript
PersistStateManager.configureStorage({
    clear: () => timer(2000).pipe(tap(_ => localStorage.clear())),
    getItem: (key: string) => timer(2000).pipe(map(_ => localStorage.getItem(key))),
    removeItem: (key: string) => timer(2000).pipe(tap(_ => localStorage.removeItem(key))),
    setItem: (key: string, value: any) => timer(2000).pipe(tap(_ => localStorage.setItem(key, value))),
    }, () => timer(2000).pipe(map(_ => Object.keys(localStorage))));
```

* passing to params when calling `save` method for example:

```typescript
this.store.select(['todos']).storage.save({ 
    storageConfig: { 
        storage: sessionStorage, getKeys: Object.keys(sessionStorage) 
        } 
    });
```

####
