Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Skip to main content
AsyncStorage is an unencrypted, asynchronous, persistent, key-value storage system that is global to the app. It should be used instead of LocalStorage. It is recommended that you use an abstraction on top of AsyncStorage instead of AsyncStorage directly for anything more than light usage since it operates globally. Vega provides AsyncStorageWithKeyScope or you can create your own abstraction. On Vega, AsyncStorage is backed by a SQLite database. 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 what is available. The AsyncStorage JavaScript code is a facade that provides a clear JavaScript API, real Error objects, and non-multi functions. Each method in the API returns a Promise object. Importing the AsyncStorage library:
Persisting data:
Fetching data:

Reference

Methods

getItem()

Fetches an item for a key and invokes a callback upon completion. Returns a Promise object. Parameters:

setItem()

Sets the value for a key and invokes a callback upon completion. Returns a Promise object. Parameters:

removeItem()

Removes an item for a key and invokes a callback upon completion. Returns a Promise object. Parameters:

mergeItem() Vega Not Available

Merges an existing key value with an input value, assuming both values are stringified JSON. Returns a Promise object. NOTE: This is not supported by all native implementations. Parameters: Example:

clear()

Erases all AsyncStorage for all clients, libraries, etc. You probably don’t want to call this; use removeItem or multiRemove to clear only your app’s keys. Returns a Promise object. Parameters:

getAllKeys() Vega Not Available

Gets all keys known to your app; for all callers, libraries, etc. Returns a Promise object. Parameters:

flushGetRequests() Vega Not Available

Flushes any pending requests using a single batch call to get the data.

multiGet()

This allows you to batch the fetching of items given an array of key inputs. Your callback will be invoked with an array of corresponding key-value pairs found:
The method returns a Promise object. Parameters: Example:

multiSet()

Use this as a batch operation for storing multiple key-value pairs. When the operation completes you’ll get a single callback with any errors.
The method returns a Promise object. Parameters:

multiRemove()

Call this to batch the deletion of all keys in the keys array. Returns a Promise object. Parameters: Example:

removeValuesForKeysWithPrefix() Vega v2

Call this to items with keys that start with a specified prefix. Returns a Promise object. Parameters: Example:

multiMerge() Vega Not Available

Batch operation to merge in existing and new values for a given set of keys. This assumes that the values are stringified JSON. Returns a Promise object. NOTE: This is not supported by all native implementations. Parameters: Example:
Last modified on May 13, 2026