Skip to main content
AsyncStorage has been extracted from React Native core.It is now maintained in a separate repository as a community package: @react-native-async-storage/async-storageThe built-in AsyncStorage module has been deprecated and removed from React Native. Please migrate to the community package.

Migration

To migrate from the deprecated built-in AsyncStorage to the community package:

1. Install the Package

or

2. Update Imports

Change your import statements: Before:
After:

3. iOS Setup

For iOS, install the pods:

4. Android Setup

No additional setup required for Android. The package will be automatically linked.

Overview

AsyncStorage is an asynchronous, persistent, key-value storage system that is global to the app. It should be used instead of LocalStorage.

Key Features

  • Asynchronous API
  • Persistent storage across app restarts
  • Simple key-value pairs
  • Supports large data sets
  • Cross-platform (iOS and Android)

Limitations

  • Stores only strings (serialize objects with JSON)
  • Not encrypted by default
  • Storage limits vary by platform
  • Not suitable for large amounts of data (consider SQLite or Realm for complex data)

Basic API

The community package maintains the same API as the original AsyncStorage:

setItem()

Stores a string value for a given key.

getItem()

Fetches a value for a given key. Returns null if not found.

removeItem()

Removes a value for a given key.

mergeItem()

Merges an existing value with a new value (assuming both values are JSON objects).

clear()

Removes all AsyncStorage data.

getAllKeys()

Returns all keys stored in AsyncStorage.

multiGet()

Fetches multiple key-value pairs.

multiSet()

Stores multiple key-value pairs.

multiRemove()

Removes multiple keys.

Examples

Store and Retrieve String

Store and Retrieve Objects

Remove Item

Get All Keys

Clear All Data

Alternatives

For more advanced storage needs, consider:

Learn More

For complete documentation, visit the official AsyncStorage repository.