An asynchronous, persistent, key-value storage system for React Native.
# Install
$ yarn add @react-native-community/async-storage
# Link
$ react-native link @react-native-community/async-storage
See docs for manual linking guide.
Note: For iOS project using pods
, run:
$ cd ios/ && pod install
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, and brownfield integration guide.
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