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
AsyncStorageWithKeyScope is an abstraction built on top of AsyncStorage for Vega. It implements the same API with some restrictions: It adds a clearScope() method to be used instead of the clear() method and Vega’s removeValuesForKeysWithPrefix() method. AsyncStorage is an unencrypted, asynchronous, persistent, key-value storage system that is global to the app. It should be used instead of LocalStorage. AsyncStorageWithKeyScope allows you to create instances with a scope prefix string you define. The instance will then transparently prepend all keys with that scope prefix followed by an _ when you make calls to the instance’s APIs and remove the prepended prefix and underscore when returning results. The AsyncStorageWithKeyScope 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 AsyncStorageWithKeyScope library:
Persisting data:
Fetching data:

Reference

Methods

constructor()

Constructs a AsyncStorageWithKeyScope instance with a designated scope prefix string. Parameters:

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.
Note: Ensure your keys are determinate or you may not be able to get or remove them later. Keys with timestamps or other variable information may be difficult to identify later and could result in wasted storage.
Parameters:

removeItem()

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

clearScope()

Remove all values in the store whose keys are prefixed with the scope prefix + ’_’. Parameters:

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.
Note: Ensure your keys are determinate or you may not be able to get or remove them later. Keys with timestamps or other variable information may be difficult to identify later and could result in wasted storage.
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:

Last modified on December 10, 2025