Skip to main content
A quick, table-first reference for the argument structure of everything exported from @glood/hydrogen. Object-typed arguments (e.g. GloodConfig, GetSectionsParams) are expanded under Parameter object shapes; full response types live in Types.
All headless calls run against API version (2 | 3, default 3). Functions marked v3-only throw when called on a v2 client.

Client

createGlood(config)

function createGlood(config: GloodConfig): GloodClient
ArgumentTypeRequiredDescription
configGloodConfigYesClient configuration. Throws if apiKey/myShopifyDomain are missing or version is not 2/3.
Returns: GloodClient

GloodClient methods

MethodArgumentsReturns
use(appModuleOrFactory)appModuleOrFactory: GloodAppModuleGloodClient (chainable)
getEnabledApps()GloodApp[]
getApp(name)name: AppName ('recommendations')GloodApp | undefined
getInitData()InitResponse | null (saved /v3/headless/init response; read-only)
setInitData(data)data: InitResponse | nullvoid (used internally by runHeadlessInit)

App module

recommendations()

function recommendations(): GloodAppModule
Takes no arguments. Pass to client.use(recommendations()).

RecommendationsApp methods

Obtain the app with client.getApp('recommendations').
MethodArgumentsReturnsNotes
getSections(params)params: GetSectionsParamsPromise<SectionsResponse>v3
getInit(params?)params?: InitParamsPromise<InitResponse>v3-only
getRecommendations(params)params: RecommendationsParamsPromise<RecommendationsResponse | V2RecommendationsResponse>version-aware
getAutomaticRecommendations(params)params: AutomaticRecommendationsParamsPromise<AutomaticRecommendationsResponse>v3-only
getTopRecommendations(params)params: TopRecommendationsParamsPromise<TopRecommendationsResponse>v3-only
sendEvent(params)params: HeadlessEventParamsPromise<HeadlessEventResponse>v3-only
trackRender(track)track: SectionTrackvoidglood:section:render
trackView(track)track: SectionTrackvoidglood:section:view
trackClick(track)track: SectionTrackvoidglood:section:click
trackAddToCart(track)track: SectionTrackvoidglood:section:add_to_cart

Components & hooks

GloodProvider(props)

function GloodProvider(props: GloodProviderProps): React.ReactElement
PropTypeRequiredDescription
clientGloodClientYesThe client from createGlood().
loaderDataanyYesRoot loader data (shop/consent context).
childrenReactNodeYesApp tree.
Subscribes to Shopify analytics and fires /v3/headless/init on mount (v3).

Hooks

HookArgumentsReturns
useGloodAnalytics()GloodClient | null
useGloodInit()InitResponse | null (v3 init response; null until resolved / for v2)
useGloodInitReady()boolean (true once page-load init has settled)
useRecommendations(params, options?)params: GetSectionsParams, options?: { skip?: boolean }UseRecommendationsResult
UseRecommendationsResult = { sections, data, loading, error, refetch, trackRender, trackView, trackClick, trackAddToCart }.

Standalone functions

All take options: HeadlessRequestOptions as the first argument.
FunctionArgumentsReturnsNotes
fetchRecommendationSections(options, params)params: GetSectionsParamsPromise<SectionsResponse>v3
fetchHeadlessInit(options, params?)params?: InitParamsPromise<InitResponse>v3-only
sendHeadlessEvent(options, params)params: HeadlessEventParamsPromise<HeadlessEventResponse>v3-only
fetchRecommendations(options, params)params: RecommendationsParamsPromise<RecommendationsResponse | V2RecommendationsResponse>version-aware
fetchV3Recommendations(options, params)params: RecommendationsParamsPromise<RecommendationsResponse>v3
fetchV2Recommendations(options, params)params: V2RecommendationsParamsPromise<V2RecommendationsResponse>v2
fetchAutomaticRecommendations(options, params)params: AutomaticRecommendationsParamsPromise<AutomaticRecommendationsResponse>v3-only
fetchTopRecommendations(options, params)params: TopRecommendationsParamsPromise<TopRecommendationsResponse>v3-only
headlessRequest(resource, body, options)resource: string, body: Record<string, any>Promise<T>low-level POST
runHeadlessInit(client)client: GloodClientPromise<InitResponse | null>no-op/null for v2

Utilities & errors

ExportArgumentsReturns
checkConsent(requiredConsents, canTrack, analytics)requiredConsents: readonly ConsentType[], canTrack: () => boolean, analytics: anyboolean
getPixelQueue(debug?)debug?: boolean (default false)PixelQueue
resetPixelQueue()void
new GloodApiError(message, status, body)message: string, status: number, body: unknownGloodApiError (.status, .body)

Parameter object shapes

GloodConfig

FieldTypeRequiredDefaultDescription
apiKeystringYesGlood storefront token (gl_sf_*).
myShopifyDomainstringYesstore-name.myshopify.com.
version2 | 3No3Headless API version.
apps{ recommendations?: RecommendationsAppConfig }NodefaultsPer-app config.
debugbooleanNofalseDebug logging.
settingsRecord<string, any>NoPassthrough settings.

HeadlessRequestOptions

FieldTypeRequiredDefaultDescription
apiKeystringYes (v3)Storefront token; bearer for v3.
myShopifyDomainstringYesSent as x-shop.
endpointstringNohttps://storefront.glood.aiEndpoint override.
version2 | 3No3API version.
debugbooleanNofalseLog request/response.

GetSectionsParams

FieldTypeRequiredDescription
pageTypePageTypeYesPage the visitor is on.
pageUrlstringNoDefaults to window.location.href in the browser.
localestringNoDefaults to navigator.language in the browser.
productIdstring | numberNoNumeric Shopify product id (product pages).
cartProductIdsArray<string | number>NoNumeric ids in cart.
sectionsnumber[]NoSpecific section ids (empty = all).
clientIdstringNoDefaults to the _glood_client_id cookie.
userIdstringNoDefaults to the init _glood_user_id cookie.
customerIdstringNoShopify customer id.
marketstringNoMarket id.
currencystringNoCurrency code.
cartValuestringNoCart total.
collectionnumberNoNumeric collection id.
qsstringNoQuery string for experience assignment.
previewbooleanNoInclude disabled sections.

InitParams

FieldTypeRequiredDescription
userIdstringNoReplays a persisted visitor id (returning visitor).
clientIdstringNoDefaults to the _glood_client_id cookie.
customerIdstringNoShopify customer id.
pageTypePageTypeNoCurrent page type.
pageUrlstringNoDefaults to window.location.href.

RecommendationQuery

FieldTypeRequiredDescription
idstringYesResult key in the response.
recommendationTypestringYesOne of RecommendationType — commonly 'similar_products' / 'bought_together'.
productIdsArray<string | number>YesAnchor product ids (v3: up to 10).
maxRecommendationsnumberNoMax results.
creationTypestringNoOne of CreationType: 'manual' | 'automatic'.
viewRecommendationViewYes'product_details' or 'product_ids'.

RecommendationsParams

FieldTypeRequiredDescription
queriesRecommendationQuery[]YesUp to 5 (v3).
clientIdstringNoVisitor client id.
userIdstringNoVisitor user id.
customerIdstringNoShopify customer id.

V2RecommendationsParams

FieldTypeRequiredDescription
queriesRecommendationQuery[]Yessimilar_products only on v2.

AutomaticRecommendationsParams

FieldTypeRequiredDescription
productIdsnumber[]YesAnchor product ids.
viewRecommendationViewYes'product_details' or 'product_ids'.
recommendationType'similar_products'NoOnly value supported.
maxRecommendationsnumberNoMax results.
filterRecord<string, any>NoVendor/tag/variant filters.
pagination{ cursor?: string | null; limit?: number }NoCursor pagination (limit default 12).

TopRecommendationsParams

FieldTypeRequiredDescription
strategyTopStrategyYes'BESTSELLERS' | 'NEW_ARRIVALS'uppercase.
viewRecommendationViewYes'product_details' or 'product_ids'.
strategyOptions{ salesTimePeriod?: 7 | 15 | 30; bestsellerMetric?: BestsellerMetric }NobestsellerMetric: 'revenue' | 'quantity' | 'orders'.
querystringNoFull-text catalog search.
filterRecord<string, any>NoVendor/tag/price/etc. filters.
facetsTopFacet[]No'vendor' | 'product_type' | 'tag' | 'price'.
pagination{ cursor?: string | null; limit?: number }NoCursor pagination (limit default 24, max 100).

HeadlessEventParams

FieldTypeRequiredDescription
event{ id, name, type, timestamp, data?, customData? }Yestype is 'standard' | 'custom'; timestamp ISO, within ±2 days.
channelHeadlessEventChannelNo'mobile' | 'headless' | 'hydrogen' (default 'hydrogen').
sessionIdstringNoDefaults to the session cookie (server requires it).
clientIdstringNoAt least one of clientId/userId required.
userIdstringNoSee above.
customerIdstringNoShopify customer id.
experiencestring | nullNoAssigned experience id.
pageTypestringNoPage type.
pageUrlstringNoPage URL.
Additional fields (e.g. cart, customer, customer_privacy, device) are passed through in the API’s snake_case wire format.

SectionTrack

FieldTypeRequiredDescription
sectionstringNoGlood section id.
sectionServeIdstringNosection_serve_id from the sections response.
requestIdstringNorequest_id from the sections response.
pagestringNoPage type of the interaction.
parent{ productId?: string; variantId?: string }NoContext product (e.g. the PDP product).
productsSectionTrackProduct[]NoProducts involved ({ productId, variantId?, quantity? }).

Enums & value sets

Several fields accept a fixed set of values. recommendationType / creationType are typed as string in the SDK (for forward-compat), but only the values below are meaningful.

RecommendationType (recommendationType)

ValueNotes
similar_productsSupported on every recommendation endpoint (v2, v3, automatic).
bought_togetherv3 /recommendations only.
recently_viewed
cross_sell
bestsellers
trending
personalized
recent_launch
collections
purchases
promoted
custom
email_recommendations
fetchV3Recommendations / getRecommendations accept any of the above, but the backend currently returns results only for similar_products and bought_together. fetchV2Recommendations and fetchAutomaticRecommendations support similar_products only.

CreationType (creationType)

Value
manual
automatic

RecommendationView (view)

ValueResult item shape
product_detailsFull product objects (RecommendedProduct).
product_ids{ product_id: number }.

TopStrategy (strategy)

Uppercase — maps directly to the backend enum.
Value
BESTSELLERS
NEW_ARRIVALS

BestsellerMetric (strategyOptions.bestsellerMetric)

Value
revenue
quantity
orders
strategyOptions.salesTimePeriod accepts 7, 15, or 30 (days).

TopFacet (facets[])

Value
vendor
product_type
tag
price

HeadlessEventChannel (channel)

ValueNotes
hydrogenDefault for this SDK.
headless
mobile

Event type (event.type)

Value
standard
custom

PageType (pageType)

product_page, collection, home, cart, order_confirm, other, blog, ajax_cart, 404, checkout, returns analytics, marketing, preferences, sale_of_data

Event names (event.name)

Standard Shopify analytics events the SDK forwards: page_viewed, product_viewed, collection_viewed, cart_viewed, search_submitted, product_added_to_cart, product_removed_from_cart. Custom attribution events: glood:section:render, glood:section:view, glood:section:click, glood:section:add_to_cart.

See Also

Types

Full request/response type definitions.

Recommendations API

Standalone function usage and endpoints.