Async Storage - jellyfish-tom/TIL GitHub Wiki

23. Explain Async Storage in React Native and also define when to use it and when to not?

  • Async Storage is the React Native equivalent of Local Storage from the web.
  • Async Storage is a community-maintained module for React Native that provides an asynchronous, unencrypted, key-value store. Async Storage is not shared between apps: every app has its own sandbox environment and has no access to data from other apps.
DO USE ASYNC STORAGE WHEN.. DON'T USE ASYNC STORAGE FOR..
Persisting non-sensitive data across app runs Token storage
Persisting Redux state Secrets
Persisting GraphQL state  
Storing global app-wide variables  

AsyncStorage is an

  • unencrypted,
  • asynchronous,
  • persistent,
  • key-value

storage system that can be accessed globally on the app. On iOS, AsyncStorage is backed by native code that stores small values in a serialized dictionary and larger values in separate files. On Android, AsyncStorage will use either RocksDB or SQLite based on availability. AsyncStorage supports only 6 MB on Android and a limitless amount of data on iOS. If you are aiming to build a cross-platform app, 6MB is the limit. The JavaScript code acts as an interface and provides clean promise-based API methods, Error objects, and non-multi functions.

The ideal place to store common data of user, app-logic and others.

⚠️ **GitHub.com Fallback** ⚠️