Skip to main content

useAsyncStorage

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

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

clear()

clear: () => Promise\<void>

Returns

Promise\<void>

getAllKeys()

getAllKeys: () => Promise\<string[]>

Returns

Promise\<string[]>

getItem()

getItem: (key) => Promise\<null | string>

Parameters
ParameterType
keystring
Returns

Promise\<null | string>

removeItem()

removeItem: (key) => Promise\<void>

Parameters
ParameterType
keystring
Returns

Promise\<void>

setItem()

setItem: (key, value) => Promise\<void>

Parameters
ParameterType
keystring
valuestring
Returns

Promise\<void>