# swr-sync-native-storage

> Synchronize SWR cache with AsyncStorage to get offline cache.

Latest version **0.0.3** (published 2021-05-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install swr-sync-native-storage
pnpm add swr-sync-native-storage
yarn add swr-sync-native-storage
bun add swr-sync-native-storage
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2021-05-03 |
| First published | 2021-04-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 2.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alireza Chassebi |
| Maintainers | alireza-chassebi |
| Keywords | Cache, Offline, React-Native, SWR, Async-Storage |

## Links

- npm: https://www.npmjs.com/package/swr-sync-native-storage
- npm.io page: https://npm.io/package/swr-sync-native-storage

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2021-05-03
- 0.0.2 — 2021-04-29
- 0.0.1 — 2021-04-29

## README

# swr-sync-native-storage

Synchronize SWR cache with AsyncStorage to get offline cache.

## Usage

Installation:

package:
`yarn add swr-sync-storage`

peer Dependencies:
`yarn add swr @react-native-async-storage/async-storage`

```javascript
import React, { useState } from 'react';
import { syncWithAsyncStorage } from 'swr-sync-native-storage';

const App = () => {
  const [isSynced, setIsSynced] = useState(null);
  useEffect(() => {
    (async () => {
      const [isSuccess, unsubscribe] = await syncWithAsyncStorage();
      setIsSynced(isSuccess);
    })();
  }, [setIsSynced]);

  return (
    <View style={{ flex: 1, justifyContent: 'center' }}>
      <Text>
        {isSynced === null ? 'Loading...' : isSynced ? 'Success' : 'Failed'}
      </Text>
    </View>
  );
};
```

The function will return a success flag & a new function to unsubscribe for cache changes.

---
_Source: https://npm.io/package/swr-sync-native-storage · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
