Storage API
The Storage API lets you persist key-value data scoped to the customer across sessions. Use this API to store customer preferences, dismissed states, or other lightweight data that should survive navigation and return visits.
Anchor to Use casesUse cases
- Remember customer preferences: Save choices like preferred language, display options, or notification settings so they persist across visits.
- Track dismissed content: Store whether a customer has dismissed a promotional banner or onboarding message so it doesn't reappear.
- Cache lightweight data: Store small pieces of data to reduce redundant API calls, such as a customer's loyalty tier or last-viewed order.
Supported targets
- customer-account.
footer. render-after - customer-account.
order-index. announcement. render - customer-account.
order-index. block. render - customer-account.
order-status. announcement. render - customer-account.
order-status. block. render - customer-account.
order-status. cart-line-item. render-after - customer-account.
order-status. cart-line-list. render-after - customer-account.
order-status. customer-information. render-after - customer-account.
order-status. fulfillment-details. render-after - customer-account.
order-status. payment-details. render-after - customer-account.
order-status. return-details. render-after - customer-account.
order-status. unfulfilled-items. render-after - customer-account.
order. action. menu-item. render - customer-account.
order. action. render - customer-account.
order. page. render - customer-account.
page. render - customer-account.
profile. addresses. render-after - customer-account.
profile. announcement. render - customer-account.
profile. block. render - customer-account.
profile. company-details. render-after - customer-account.
profile. company-location-addresses. render-after - customer-account.
profile. company-location-payment. render-after - customer-account.
profile. company-location-staff. render-after - customer-account.
profile. payment. render-after
Supported targets
- customer-account.
footer. render-after - customer-account.
order-index. announcement. render - customer-account.
order-index. block. render - customer-account.
order-status. announcement. render - customer-account.
order-status. block. render - customer-account.
order-status. cart-line-item. render-after - customer-account.
order-status. cart-line-list. render-after - customer-account.
order-status. customer-information. render-after - customer-account.
order-status. fulfillment-details. render-after - customer-account.
order-status. payment-details. render-after - customer-account.
order-status. return-details. render-after - customer-account.
order-status. unfulfilled-items. render-after - customer-account.
order. action. menu-item. render - customer-account.
order. action. render - customer-account.
order. page. render - customer-account.
page. render - customer-account.
profile. addresses. render-after - customer-account.
profile. announcement. render - customer-account.
profile. block. render - customer-account.
profile. company-details. render-after - customer-account.
profile. company-location-addresses. render-after - customer-account.
profile. company-location-payment. render-after - customer-account.
profile. company-location-staff. render-after - customer-account.
profile. payment. render-after
Anchor to PropertiesProperties
The shopify global object provides key-value storage scoped to the customer. Access the following properties on shopify to read, write, and delete persistent data across sessions.
- Anchor to storagestoragestorageStorageStoragerequiredrequired
Key-value storage that persists across customer sessions for this extension target. Use this to store preferences, dismiss states, or cached data without requiring a backend call.
Storage
Key-value storage for a specific extension. Use storage to save preferences or cached data that should survive page reloads without requiring a backend call. Stored data is only available to this specific extension. The storage backend is implemented with `localStorage` and data persistence isn't guaranteed.
- delete
Deletes a previously stored value 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 type. Returns the stored value for the given key, or `null` when no value exists. Doesn't throw on a missing key.
<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>
Anchor to Best practicesBest practices
- Store only small values: Keep stored data lightweight. Storage is intended for simple key-value pairs like preferences and flags, not large datasets.
- Use descriptive keys: Name your storage keys clearly (for example,
promo_dismissedorlocale_pref) so their purpose is obvious and conflicts with other extensions are unlikely. - Handle missing values gracefully: Always check for
nullorundefinedwhen reading from storage, since the value may not exist on the customer's first visit. - Don't store sensitive data: Storage isn't encrypted. Don't store personal information, tokens, or anything that could compromise customer privacy.
Anchor to LimitationsLimitations
- Storage is scoped per customer and per extension. You can't share data between different extensions or access another customer's stored values.
- On the pre-authenticated Order status page, storage is scoped to the customer associated with the order, not the browsing session.
- All values are stored as strings. You must serialize and deserialize complex types (like JSON objects).