--- title: Storage API description: |- The Storage API allows fetching, setting, updating, and clearing an extension's data from the POS local storage. - An extension can store up to 100 entries. - The maximum size for a key is ~1 KB, and for a value is ~1 MB. - If a target (such as `pos.home.tile.render`) is disabled or removed, the extension data remains. - All stored extension data that has not been updated for a month is cleared automatically after that period. api_version: 2025-10 api_name: pos-ui-extensions source_url: html: https://shopify.dev/docs/api/pos-ui-extensions/latest/apis/storage-api md: https://shopify.dev/docs/api/pos-ui-extensions/latest/apis/storage-api.md --- # Storage APIAPIs The Storage API allows fetching, setting, updating, and clearing an extension's data from the POS local storage. * An extension can store up to 100 entries. * The maximum size for a key is \~1 KB, and for a value is \~1 MB. * If a target (such as `pos.home.tile.render`) is disabled or removed, the extension data remains. * All stored extension data that has not been updated for a month is cleared automatically after that period. ## StorageApi * clear () => Promise\ required Clears the storage. * delete \(key: Keys) => Promise\ required Deletes a key from the storage. * entries \() => Promise<\[Keys, StorageTypes\[Keys]]\[]> required Gets all the keys and values in the storage. * get \(key: Keys) => Promise\ required Gets the value of a key in the storage. * set \(key: Keys, value: StorageTypes\[Keys]) => Promise\ required Sets the value of a key in the storage. ## Examples Examples of using the Storage API Getting a single value from storage Setting a single value in storage Deleting a single value from storage Clear all entries for an extension from storage Retrieve all entries for an extension from storage ### Examples * #### Getting a single value from storage ##### jsx ```jsx import {render} from 'preact'; export default async () => { render(, document.body); } function Extension() { return ( { const storedData = await shopify.storage.get('key'); shopify.toast.show(String(storedData ?? '')); }} /> ); } ``` * #### Setting a single value in storage ##### jsx ```jsx import {render} from 'preact'; export default async () => { render(, document.body); } function Extension() { return ( { await Promise.all([ shopify.storage.set('trackingId', 'd6ead53c-b5f5-0b16-dabb-17081ff238c3'), shopify.storage.set('someObject', { boolean: true, numeric: 2, string: 'Hello world!', }), shopify.storage.set('attempts', 2), ]); shopify.toast.show('Data stored'); }} /> ); } ``` * #### Deleting a single value from storage ##### jsx ```jsx import {render} from 'preact'; export default async () => { render(, document.body); } function Extension() { return ( { await shopify.storage.set('key', 'A temporary value'); const storedData = await shopify.storage.get('key'); shopify.toast.show(`Current value: ${String(storedData)}`); setTimeout(async () => { await shopify.storage.delete('key'); const storedData = (await shopify.storage.get('key')) ?? ''; shopify.toast.show(`Current value after deletion: ${String(storedData)}`); }, 2000); }} /> ); } ``` * #### Clear all entries for an extension from storage ##### jsx ```jsx import {render} from 'preact'; import {useState, useEffect} from 'preact/hooks'; export default async () => { render(, document.body); } function Extension() { const [itemCount, setItemCount] = useState(0); useEffect(() => { const initializeData = async () => { const count = 10; for (let i = 0; i < count; i++) { await shopify.storage.set(`key-${i}`, `value-${i}`); } setItemCount(count); }; initializeData(); }, []); return ( { await shopify.storage.clear(); shopify.toast.show('All data cleared'); setItemCount(0); }} /> ); } ``` * #### Retrieve all entries for an extension from storage ##### jsx ```jsx import {render} from 'preact'; export default async () => { render(, document.body); } function Extension() { return ( { await shopify.storage.set('attempts', 2); await shopify.storage.set('darkMode', true); await shopify.storage.set('trackingId', 'd6ead53c-b5f5-0b16-dabb-17081ff238c3'); const allEntries = await shopify.storage.entries(); const message = allEntries.length ? allEntries.map(([key, value]) => `${key}: ${value}`).join(', ') : 'Nothing stored'; shopify.toast.show(message); }} /> ); } ```