Reading and Writing with AsyncStorage
Install @react-native-async-storage/async-storage, use setItem and getItem to store and retrieve string values, and handle the returned Promises correctly.
What Is AsyncStorage?
AsyncStorage is React Native's persistent key-value storage system. It stores data as strings on the device's local file system, making it available even after the app is closed and reopened. It works on both iOS and Android and supports any string-serializable value. All operations are asynchronous and return Promises, so you must await them or chain .then().
Installing the Package
The community AsyncStorage package must be installed separately in modern React Native and Expo projects. It is no longer bundled with React Native core. Use npx expo install (instead of plain npm) so Expo picks the compatible version for your SDK.
npx expo install @react-native-async-storage/async-storageAll lessons in this course
- Reading and Writing with AsyncStorage
- Storing and Parsing JSON Objects
- Building a Persistent Settings Screen
- Clearing Storage and Migration Strategies