# redux-remote-persist

> Persist and rehydrate a redux store to remote and local storage.

Latest version **1.0.2** (published 2020-05-21) · MIT license · 0 weekly downloads

## Install

```sh
npm install redux-remote-persist
pnpm add redux-remote-persist
yarn add redux-remote-persist
bun add redux-remote-persist
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-05-21 |
| First published | 2020-03-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 3 |
| Unpacked size | 178.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Andrej Česen |
| Maintainers | andrejsowa |

## Links

- npm: https://www.npmjs.com/package/redux-remote-persist
- Repository: https://github.com/SowaLabs/redux-remote-persist
- npm.io page: https://npm.io/package/redux-remote-persist

## Dependencies (3)

- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [lodash-es](https://npm.io/package/lodash-es.md) ^4.17.15
- [safetypings](https://npm.io/package/safetypings.md) ^0.1.0

## Recent versions

- 1.0.2 (latest) — 2020-05-21
- 1.0.1 — 2020-05-21
- 1.0.0 — 2020-05-20
- 0.1.0 — 2020-03-03

## README

# Redux Remote Persist

Persist and rehydrate a redux store to remote and local storage.

## Usage

`yarn add redux-persist`

1. Add epic to `redux-observable`:

```js
import AsyncStorage from '@react-native-community/async-storage';

const remotePersistEpic = createRemotePersistEpic({
  // used internally
  getPersistState: (state) => state.persist,
  remoteStorageFetchAjax: (action$, state$, { ajax }) => ajax({ url: '/fetch' }),
  remoteStorageUpdateAjax: (payload) => (action$, state$, { ajax }) =>
    ajax({ url: '/update', body: payload }),
  handleAjaxError: (action$, errorAction) => (error, source) => of(errorAction(error)),
  localStorageKey: 'myapp',
  persistDebounceTime: 5000,
  // select states which we want to persist
  persistSelectors: {
    'myapp-settings': (state) => state.settings,
    'myapp-storereview': (state) => state.storeReview,
  },
  // select states which we want to rehydrate
  rehydrateSelectors: {
    'myapp-settings': (state) => state.settings,
    'myapp-config': (state) => state.config,
    'myapp-storereview': (state) => state.storeReview,
  },
  storage: AsyncStorage,
});
```

2. Integrate reducers:

```js
// configureStore.js

import { remotePersistInternalReducer, remotePersistReducer } from 'redux-remote-persist';

import config from './reducers/config';
import settings from './reducers/settings';
import storeReview from './reducers/storeReview';

// root reducer
const appReducer: any = combineReducers({
  // remote persist reducers
  config: remotePersistReducer({ key: 'myapp-config' }, config), // read-only state
  settings: remotePersistReducer({ key: 'myapp-settings' }, settings),
  // WARNING: use all lower case keys! e.g. 'myapp-storereview' (remote supports only all lowercase)
  storeReview: remotePersistReducer({ key: 'myapp-storereview' }, storeReview),

  // used internally by redux-remote-persist
  persist: remotePersistInternalReducer,
});
```

3. (optional) Use actions to hook into `redux-remote-persist`:

```js
import { actions } from 'redux-remote-persist';
```

---
_Source: https://npm.io/package/redux-remote-persist · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
