Skip to main content

Storage
API

The API for interacting with local storage.

The base API object provided to purchase, and customer-account.order-status extension targets.

required

Key-value storage for the extension. Uses localStorage and should persist across the buyer's current checkout session. However, data persistence isn't guaranteed and storage is reset when the buyer starts a new checkout.

Data is shared across all activated extension targets of this extension. In versions <=2023-07, each activated extension target had its own storage.

Was this section helpful?

Returns the key-value Storage interface for the extension target.

Storage

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.

Was this section helpful?