use Storagehook
Returns the key-value Storage
interface for the extension point.
Anchor to useStorageuse Storage()
Anchor to useStorage-returnsReturns
- read<T = unknown>(key: string) => Promise<T>
Read and return a stored value by key.
The stored data is deserialized from JSON and returned as its original primitive.
Returns
null
if no stored data exists.- write(key: string, data: any) => Promise<void>
Write stored data for this key.
The data must be serializable to JSON.
- delete(key: string) => Promise<void>
Delete stored data by key.
Storage
Storage
A key-value storage object for extension points. Stored data is only available to this specific app at this specific extension point. The storage backend is implemented with `localStorage` and should persist across the buyer's checkout session. However, data persistence isn't guaranteed.
- read
Read and return a stored value by key. The stored data is deserialized from JSON and returned as its original primitive. Returns `null` if no stored data exists.
<T = unknown>(key: string) => Promise<T>
- write
Write stored data for this key. The data must be serializable to JSON.
(key: string, data: any) => Promise<void>
- delete
Delete stored data by key.
(key: string) => Promise<void>
export interface Storage {
/**
* Read and return a stored value by key.
*
* The stored data is deserialized from JSON and returned as
* its original primitive.
*
* Returns `null` if no stored data exists.
*/
read<T = unknown>(key: string): Promise<T | null>;
/**
* Write stored data for this key.
*
* The data must be serializable to JSON.
*/
write(key: string, data: any): Promise<void>;
/**
* Delete stored data by key.
*/
delete(key: string): Promise<void>;
}