--- title: Storage description: The API for interacting with local storage. api_version: 2026-01 api_name: checkout-ui-extensions source_url: html: https://shopify.dev/docs/api/checkout-ui-extensions/latest/apis/storage md: https://shopify.dev/docs/api/checkout-ui-extensions/latest/apis/storage.md --- # Storage The API for interacting with local storage. ## StandardApi The base API object provided to `purchase` extension targets. * **storage** **Storage** **required** The key-value storage for the extension. It uses `localStorage` and should persist across the customer's current checkout session. **Caution:** Data persistence isn\'t guaranteed and storage is reset when the customer starts a new checkout. Data is shared across all activated extension targets of this extension. In versions 2023-07 and earlier, each activated extension target had its own storage. ### Storage A key-value storage object for the extension. Stored data is only available to this specific extension and any of its instances. The storage backend is implemented with \`localStorage\` and should persist across the buyer's checkout session. However, data persistence isn't guaranteed. * delete Delete stored data by key. ```ts (key: string) => Promise ``` * 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. ```ts (key: string) => Promise ``` * write Write stored data for this key. The data must be serializable to JSON. ```ts (key: string, data: any) => Promise ``` ## use​Storage() Returns the key-value `Storage` interface for the extension target. ### Returns * **Storage** ### ### StorageA key-value storage object for the extension.Stored data is only available to this specific extension and any of its instances.The storage backend is implemented with `localStorage` and should persist across the buyer's checkout session. However, data persistence isn't guaranteed. * **delete** **(key: string) => Promise\** Delete stored data by key. * **read** **\(key: string) => Promise\** 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\** Write stored data for this key. The data must be serializable to JSON. ### Storage A key-value storage object for the extension. Stored data is only available to this specific extension and any of its instances. The storage backend is implemented with \`localStorage\` and should persist across the buyer's checkout session. However, data persistence isn't guaranteed. * delete Delete stored data by key. ```ts (key: string) => Promise ``` * 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. ```ts (key: string) => Promise ``` * write Write stored data for this key. The data must be serializable to JSON. ```ts (key: string, data: any) => Promise ``` Examples ### Examples * #### Storage ##### Preact ```jsx import '@shopify/ui-extensions/preact'; import {render} from 'preact'; import {useEffect, useState} from 'preact/hooks'; export default function extension() { render(, document.body); } function Extension() { const {storage} = shopify; const [tosConsent, setTosConsent] = useState(false); useEffect(() => { async function readFromStorage() { const tosConsent = await storage.read( 'tos-consent', ); setTosConsent(Boolean(tosConsent)); } readFromStorage(); }, [storage]); async function cacheConsent(value: boolean) { setTosConsent(value); await storage.write('tos-consent', value); } return ( cacheConsent(!tosConsent)} label="I agree with the terms of service" /> ); } ``` ## Related [Reference - Targets](https://shopify.dev/docs/api/checkout-ui-extensions/targets) [Reference - Components](https://shopify.dev/docs/api/checkout-ui-extensions/components) [Reference - Configuration](https://shopify.dev/docs/api/checkout-ui-extensions/configuration) [Learn - Tutorials](https://shopify.dev/apps/checkout)