https://github.com/aveq-research/localforage-asyncstorage-driver
Driver which enables you to use localforage for React-Native's AsyncStorage API
https://github.com/aveq-research/localforage-asyncstorage-driver
asyncstorage asyncstorage-wrapper localforage localforage-driver react-native react-native-storage
Last synced: 5 months ago
JSON representation
Driver which enables you to use localforage for React-Native's AsyncStorage API
- Host: GitHub
- URL: https://github.com/aveq-research/localforage-asyncstorage-driver
- Owner: aveq-research
- License: mit
- Created: 2020-05-05T08:51:27.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-07-21T23:09:08.000Z (11 months ago)
- Last Synced: 2025-10-11T07:56:24.334Z (8 months ago)
- Topics: asyncstorage, asyncstorage-wrapper, localforage, localforage-driver, react-native, react-native-storage
- Language: JavaScript
- Homepage:
- Size: 696 KB
- Stars: 21
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# localforage-asyncstorage-driver
[](https://badge.fury.io/js/%40aveq-research%2Flocalforage-asyncstorage-driver)
This Library contains a driver which enables to use [localforage](https://github.com/localForage/localForage) for React-Native's [AsyncStorage](https://github.com/react-native-community/async-storage).
## Peer Dependencies
Please note! With the switch to v3.0.0 `@react-native-async-storage/async-storage` became a peer dependency!!
## Setup
Simply install the driver via NPM:
`npm i --save @aveq-research/localforage-asyncstorage-driver`
If not done yet, make sure to have the appropriate peer dependencies (`react` resp. `react-native`) to be installed.
## Usage
It delivers three different methods to create an appropriate driver:
- `driverWithoutSerialization()`: Create a common AsyncStorage driver which does not serialize any data automatically; you need to integrate your own serialization!
- `driverWithSerialization(serializer)`: Creates an AsyncStorage driver with the given serializer; A valid serializer needs to contain a `serialize` and `deserialize` method
- `driverWithDefaultSerialization()`: Will use the default serialization from localforage
Working Code Example:
```js
import { driverWithoutSerialization } from '@aveq-research/localforage-asyncstorage-driver';
const driver = driverWithoutSerialization();
await localforage.defineDriver(driver);
await localforage.setDriver(driver._driver); // i.e. "rnAsyncStorageWrapper"
```
Alternatively with instance usage:
```js
import { driverWithoutSerialization } from '@aveq-research/localforage-asyncstorage-driver';
const driver = driverWithoutSerialization();
const instance = localforage.createInstance({ driver });
```
After that you may use localforage as you know it already. For further questions concerning the localforage API, lookup https://github.com/localForage/localForage
## License
This driver is distributed under
MIT License (see [LICENSE](https://github.com/aveq-research/localforage-asyncstorage-driver/blob/master/LICENSE)) and maintained by the wonderful [AVEQ](https://aveq.info) team.