AppbrewDevelopers
ReferencePackages

@gauntlet/state

Hooks for app state, products, cart, user, and settings.

@gauntlet/state is how your code reads and changes anything in the app: block config, products, the cart, the signed-in user, navigation, Shopify data. It is a Zustand-backed store, but you reach it only through hooks.

import { useBlock, useBlockSettings, useProductByHandle, useAddToCart } from '@gauntlet/state'

Three rules apply to every hook here:

  1. Type the result. Query and metafield hooks return unknown-shaped data; assert your own interface.
  2. Null-check before use. Data arrives async — every result can be undefined on first render.
  3. Read config through useBlockSettings, never from props — it applies the full settings-precedence chain (Config and theme).

For the conceptual model behind these hooks, read State and data first.

Hooks by module

block

HookParametersWhen to use
useBlockStylethe block from useBlockResolved style for the block: theme style → theme variant → instance style, deep-merged.
useBlockSettingsthe block from useBlock; optional { extends } to inherit a parent block’s settingsRead your block’s merged config (global settings → variant → instance). Never read source/options off props directly.
useBlockTestIDblock, screenId, optional suffixStable testID for E2E selectors on a block instance.

cart

HookParametersWhen to use
useBuyNowproduct handle; optional checkForRequirementsSkip-the-cart purchase action for a product.
useCartItemsJust the line items when you don’t need the whole cart.
useBackInStockNotificationsgetProduct: (productHandle: string) => any, handle: string, variantId: any, toastSettin…
useCheckoutoptional sign-in modal control and continuationStarts checkout, routing through login when the store requires it.
useUpdateUserAddressBasedOnLocalization

common

HookParametersWhen to use
useIsStateTruthystr: string
useIsStatusIdlestr: string

constants

HookParametersWhen to use
useConstants
HookParametersWhen to use
useDeepLink

estimated-delivery-date

HookParametersWhen to use
useEdd

filter

HookParametersWhen to use
useSetSortKey
useQueryData
useSetQueryData
usePriceData
useResetFilters
useFilterStaticData

hooks

HookParametersWhen to use
useBlockscreenId, componentId, instanceId — all from your BaseBlockPropsFirst call in every block: resolves this placement’s config entry from state.
useAppBarscreenId: string
useProductTagsproductHandle: string
useProductTypeproductHandle: string
useCollectionId{ id, handle, }
useCheckAndFullfillRequireMentsoptions
useAddToCartproduct handle; optional checkForRequirementsReturns the add-to-cart action for a product; handles requirement checks (e.g. variant selected).
useUpdateQuantityForLineItem
useUpdateQuantityForLineItems
useUpdateSellingPlanForLineItem
useApplyDiscountCodeApply a discount code to the cart; pair with useRemoveDiscountCode.
useRemoveDiscountCode
useRemoveItemFromCart
useResetCart
useClearGiftItems
useLineItemsLine items enriched for display (images, options). Prefer useLineItemsV2 in new code.
useLineItemsV2
useCartThe cart object: items, totals, discounts. Re-renders on cart changes.
useModalOpen and close app modals from block code.
useAddress
useUserThe signed-in customer (or undefined). Gate account-only UI on it.
usePaymentUrl
useDomain
useCheckoutInfoscreenId: string
useVariants
useSellingPlan
useVariantsWithSubscription
useSelectDefaultVariantPreselect a sensible default variant when a product screen mounts.
useSearch{ searchKey, limit }Search results for a query against the store catalog.
useDebouncevalue, delay msDebounced value — search inputs and other rapid-fire state.
useAddressFromStorage
useDeviceDimensionsLive screen dimensions for responsive sizing.
useDeviceDevice info (platform, notch…) for platform-aware rendering.
useThemeTheme tokens (colors, fonts) for styling custom UI consistently.
useSettingsRaw settings map for the app. Usually you want useBlockSettings or useGlobalSettings instead.
useGlobalStyleApp-wide style defaults blocks inherit.
useConfigThe whole app config document. Prefer narrower hooks; reach for this in shell-level code.
useProductproductIdProduct data by id, from store cache or fetched remotely.
useProductByHandleproduct handleProduct data by handle — the common choice inside product blocks.
useProductsByHandlesarray of product handlesBatch variant of useProductByHandle for lists and carousels.
useCollectionTitle
useCollectionThe active collection and its products on collection screens.
useLoadMore
useFormDataFromStorage
useReRenderKeyGenerates a key that forces a React component to re-render when dependencies change.

localization

HookParametersWhen to use
useLocalizationActive country/currency localization state.
useCountryCode
useCurrencyCodeThe active currency code for formatting.
useCurrencySymbolcurrencyCode: string
usePricea price valueFormat a price in the shopper’s active currency, conversion included.
useConversionRates

metafield

HookParametersWhen to use
useCollectionMetafieldscollectionId + array of { namespace, key }Collection-level metafields (by-handle variant available).
useCollectionMetafieldsByHandlecollectionHandle: string | undefined, listOfNamespaceAndKeys
useMultipleMetafieldsproduct handle + array of { namespace, key } descriptorsRead product metafields. Assert your own result interface and null-check before access.
useMetafieldQueryproduct handle, { namespace, key } list, query optionsMetafield read with query control (e.g. reference resolution) when useMultipleMetafields is not enough.
useShopifyMediaImagesids: Array<MediaImageId> | null, productHandle: string, namespaceAndKeyObj
useCollectionMetafieldsQuerycollectionId: string | null | undefined, namespaceAndKeys: Array<Metafield> | Metafield…
HookParametersWhen to use
useBottomSheetModalBottom-sheet variant of useModal.
useCloseModalOnHardwarebackPress

module

HookParametersWhen to use
useModulemodule nameAccess optional platform modules (wishlist, reviews…) that may or may not be enabled for the app.
useWishlistThe wishlist module when enabled: items plus add/remove actions.
useAnalyticsThe analytics module — track custom events from blocks through every configured tracker.

order

HookParametersWhen to use
useOrderDetailsorderIdOne order’s details for order-history and post-purchase surfaces.

plp-grid

HookParametersWhen to use
usePlpGridToggleGrid density on the current product listing: the offered layouts, the active one, and a setter — for building your own density toggle.

product

HookParametersWhen to use
useProductRecommendationshandle: string, mode: 'RELATED' | 'COMPLEMENTARY'
useProductDescriptionhandle: string
useRecentlyViewedProductshandle: ProductHandleReturns {status, data}
useProductByIdsproductIds: Array<ProductId> | null, hideUnavailableProducts

quantity-restriction

HookParametersWhen to use
useQuantityLimitInCartproductTags: Array<string>
useMaxVariantInventoryitem: BaseLineItem

reviews

HookParametersWhen to use
useProductReviewSummaryproductId: string
useProductReviewsproductId: string

rewards

HookParametersWhen to use
useRewards
useReferralHistory
useWalletTransactions
useRedeemedRewards
useRewardsProgram

route

HookParametersWhen to use
useReplaceScreenReplace the current screen instead of pushing — for redirects.
useLinkReturns the navigate action used across the app — screens, products, URLs. The standard way to link.
useRouteThe current route and its params.
useRouteName
useSetWebUrl
useSetOverrideBack

screen

HookParametersWhen to use
useBlockLocationparams: BlockVisibilityParams
useActiveScreen
HookParametersWhen to use
useSearchKey
useSetSearchKey
useGetSearchSuggestion
useIsSearchActive
useSetIsSearchActive
useSuggestions{ allowEmpty, limit, }
useSuggestionsV2{ allowEmpty, limit, }
useGetSearchResults
usePastSearches
useSetPastSearches
useTrendingProductslimit: number
useSearchRecommendation{ type, limit, idSource, }
useTrendingSearches{ limit }: { limit?: number }

settings

HookParametersWhen to use
useGlobalSettingsApp-wide settings that are not tied to one block.
useIntegrationSettingsthe integration’s configKeyYour integration’s merchant-entered settings from integrations.<configKey>. Type the result.

shipping-address

HookParametersWhen to use
useShippingAddress

shop

HookParametersWhen to use
useShop

shopify-query

HookParametersWhen to use
useShopifyQuerya Storefront GraphQL query stringRun a typed Storefront query: const data = useShopifyQuery<MyResult>(query). Always null-check.

sizing

HookParametersWhen to use
useSizeGuide

title

HookParametersWhen to use
useTitlerouteName: string, screenId: string, params: any, options: Record<string, any>

variant-selector

HookParametersWhen to use
useVariantSelectoroptions object: productData plus display/selection optionsThe variant-selection engine behind option pickers — selected options, available values, image switching.

video

HookParametersWhen to use
useVideoState{ componentId, instanceId, index, options, }: useVideoStateProps

On this page