Skip to main content

hooks_useAsyncStorage

@shopify/shop-minis-platform-sdk / hooks/useAsyncStorage

Module: hooks/useAsyncStorage

Table of contents

Functions

Functions

useAsyncStorage

useAsyncStorage(): Object

The useAsyncStorage hook is a wrapper around AsyncStorage that allows you to store small amounts of data in the device's local storage as key-value pairs. Due to limitations in AsyncStorage, it is not recommended to store large amounts of data in this way.

All data passed in and out of the hook should be serialized and deserialized using JSON.stringify and JSON.parse by the caller. As such, it is not recommended to store functions or other non-serializable data types.

Returns

Object

getItem, setItem, removeItem, getAllKeys, clear

NameType
clear() => Promise<void>
getAllKeys() => Promise<string[]>
getItem(key: string) => Promise<null | string>
removeItem(key: string) => Promise<void>
setItem(key: string, value: string) => Promise<void>