swish.storefront namespace provides a client for the Shopify Storefront API. It handles authentication, localization (country/language from your storefront context), and response caching automatically.
StorefrontApiResponse:
loadProduct(args)
Load product and variant data.
Either
productId or productHandle is required.
StorefrontApiResponse<{ product: Product | null; variant: ProductVariant | null }>.
loadResolvedProduct(args)
Load a single product in a render-ready shape. Unlike loadProduct, this transparently resolves combined listings: it detects when a product belongs to a combined listing, loads the parent, and returns a product with the parent’s options and availability matrix overlaid on the active child. This is the same resolution the built-in Swish UI uses, so a custom page renders variants identically.
Either
productId or productHandle is required.
Promise<{ product: Product | null; variant: ProductVariant | null }>. Resolution failures past the initial fetch degrade gracefully (a warning is logged and the unresolved product is returned) rather than throwing.
Build a custom wishlist page
To render a custom wishlist page, load the saved items (IDs only) and resolve each one withloadResolvedProduct. Products are cached individually, so repeat views and products shared across multiple lists are served from cache, and concurrent cache misses are automatically coalesced into batched Storefront requests.
Fire the calls concurrently with Promise.all rather than a sequential for loop: batching only kicks in when the loadResolvedProduct calls happen in the same tick, so a parallel map coalesces them into batched requests while a sequential loop pays one round-trip per item. You can pass an item straight through — it reads productId/variantId and ignores the rest. Keep each item next to its resolved product so you still have item.id (to unsave), item.quantity, and other fields when rendering.
loadProductImages(args)
Load images for multiple products at once. Useful for rendering product grids without fetching full product data.
StorefrontApiResponse<Array<{ id: string; altText: string; url: string }>>. On error, data is null and errors contains the error.
loadProductRecommendations(args)
Load product recommendations from Shopify.
Either
productId or productHandle is required.
StorefrontApiResponse<{ productRecommendations?: Product[] | null }>.
loadProductId(args)
Resolve a product ID from a handle. Used internally by the SDK when only a handle is available (e.g. from a URL).
loadProductHandle(args)
Resolve a product handle from an ID. The inverse of loadProductId - useful when you have a saved item (which stores IDs) and need to build a link to the product page.
productId is missing.
loadCollectionProducts(args)
Load a page of products from a Shopify collection. Country and language are injected from your storefront context automatically.
title, handle, and onlineStoreUrl alongside the page of products. Each product node carries only its id - pass those to loadProduct or loadResolvedProduct when you need full product data. Throws when handle is missing.
query(query, variables)
Run a custom Storefront API GraphQL query. Country and language from the storefront context are included automatically via the @inContext directive.
StorefrontApiResponse<TData>.
fetch(input, init?)
Low-level fetch with caching. Sends a request through the Storefront API client’s cache layer.
Returns
Promise<Response>.