An asynchronous, unencrypted, persistent, key-value storage system for React Native.
Release Candidate for AsyncStorage v2 is out. More info can be found here..
$ yarn add @react-native-community/async-storage
- React Native 0.60+
CLI autolink feature links the module while building the app.
- React Native <= 0.59
$ react-native link @react-native-community/async-storage
Note For iOS
using cocoapods
, run:
$ cd ios/ && pod install
See docs for manual linking guide
New React Native comes with autolinking
feature, which automatically links Native Modules in your project.
In order to get it to work, make sure you unlink
Async Storage
first:
$ react-native unlink @react-native-community/async-storage
import AsyncStorage from '@react-native-community/async-storage';
storeData = async () => {
try {
await AsyncStorage.setItem('@storage_Key', 'stored value')
} catch (e) {
// saving error
}
}
getData = async () => {
try {
const value = await AsyncStorage.getItem('@storage_Key')
if(value !== null) {
// value previously stored
}
} catch(e) {
// error reading value
}
}
See docs for api and more examples or advanced usages.
Using Jest for testing? Make sure to check out docs on how to integrate it with this module.
See the CONTRIBUTING file for how to help out.
MIT