Storage Backend: Web
Storage backend for Async Storage
, targeting Web platform.
Installation
- Get the core
$ yarn add @react-native-community/async-storage@next
- Get the the storage
$ yarn add @react-native-community/async-storage-backend-web@next
Usage
import WebStorage from '@react-native-community/async-storage-backend-web';
import AsyncStorageFactory from '@react-native-community/async-storage';
type MyModel = {
userName: string,
userId: number
};
const webStorage = new WebStorage('idb');
const storage = AsyncStorageFactory.create<MyModel>(webStorage);
export default storage;
Storage Options
values: idb
| local
| session
description: Type of store to be used. idb
is implemented with IndexedDB, largely based on async-storage by Mozilla, while local
and session
refers to localStorage
and sessionStorage
respectively.
License
MIT.