Skip to main content

Storage API

The Storage API provides key-value storage that persists across page loads within the current checkout session. Use this API to save and restore extension state, such as dismissed banners, form progress, or buyer preferences, so that the buyer doesn't lose context when navigating between checkout steps.

Storage is scoped to your extension. Other extensions can't read or write your stored data.

  • Persist dismissed banners: Save whether the buyer has dismissed a promotional banner so it stays hidden when they navigate back.
  • Restore form state: Store partially completed form data so that the buyer doesn't have to re-enter it after navigating away and returning.
  • Track extension state: Save flags or counters that your extension needs to maintain across page loads within the checkout.
Support
Targets (33)

Anchor to Properties and methodsProperties and methods

The shopify global object provides session storage for the current checkout. Access the following properties and methods on shopify to read, write, and delete stored values. Available to purchase extension targets.

Anchor to storage
storage
required

Key-value storage that persists across page loads within the current checkout session. Data is shared across all activated targets associated with this extension.

Caution

Data persistence isn't guaranteed and storage is cleared when the buyer starts a new checkout.


  • Store only small, serializable values: Storage uses localStorage under the hood. Keep stored data small and JSON-serializable to avoid unexpected behavior.
  • Use delete() instead of writing empty values: To remove a stored entry, call storage.delete(key) rather than writing null or an empty string. This keeps your storage clean and avoids ambiguity when checking for missing keys.

  • Stored data persists only for the current checkout session. After checkout completes or the session expires, all stored values are cleared. Data persistence within a session isn't guaranteed, so don't rely on storage for critical checkout states.

Was this page helpful?