StorageAPI
The API for interacting with local storage.
Anchor to standardapiStandardApi
The base API object provided to this and other customer-account
extension targets.
- Anchor to storagestoragerequired
Key-value storage for the extension target.
Docs_Standard_StorageApi
- storage
Key-value storage for the extension target.
Storage
export interface Docs_Standard_StorageApi
extends Pick<StandardApi<any>, 'storage'> {}
Storage
A key-value storage object for extension targets. Stored data is only available to this specific app but can be shared across multiple extension targets. The storage backend is implemented with `localStorage` and should persist for ... days However, data persistence isn't guaranteed.
- delete
Delete stored data by key.
(key: string) => Promise<void>
- 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>
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>;
}
Anchor to useStorageuse Storage()
Returns the key-value Storage
interface for the extension target.
Anchor to useStorage-returnsReturns
- delete(key: string) => Promise<void>
Delete stored data by key.
- 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.
Storage
UseStorageGeneratedType
Returns the key-value `Storage` interface for the extension target.
Storage
export function useStorage<
Target extends RenderExtensionTarget = RenderExtensionTarget,
>(): Storage {
return useApi<Target>().storage;
}
Storage
A key-value storage object for extension targets. Stored data is only available to this specific app but can be shared across multiple extension targets. The storage backend is implemented with `localStorage` and should persist for ... days However, data persistence isn't guaranteed.
- delete
Delete stored data by key.
(key: string) => Promise<void>
- 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>
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>;
}