Skip to main content

TypeScript Types

The Glood Hydrogen SDK is built with TypeScript-first design, providing comprehensive type definitions for all interfaces, configurations, and data structures.

Core Configuration Types

GloodConfig

Main configuration interface for creating a Glood client.
Usage:

PixelConfig

Configuration for pixel tracking per app.
pixel.endpoint is retained for backward compatibility but no longer determines where events are sent. Events are routed by the client’s version off the app’s main endpoint (v3 → /api/storefront/v3/headless/events, v2 → /api/storefront/event). pixel.enabled and pixel.consent still apply.
Usage:

App Configuration Types

RecommendationsAppConfig

Configuration specific to the recommendations app.

Client & App Types

GloodClient

The main client interface returned by createGlood().

GloodApp

Interface representing an individual app instance.

GloodAppModule

Function type for app module factories.
Usage:

React Component Types

GloodProviderProps

Props for the GloodProvider React component.
Usage:

Analytics Event Data Types

PageViewData

Data structure for page view events.

ProductViewData

Data structure for product view events.

SearchData

Data structure for search events.

CollectionViewData

Data structure for collection view events.

CartViewData

Data structure for cart view events.

Recommendations API Types

GetSectionsParams

Parameters for fetching recommendation sections — used by both useRecommendations() and fetchRecommendationSections().
Usage:

SectionsResponse

Full response from the sections API.

RecommendationSection

A recommendation section configured in the Glood dashboard, served with its products.

SectionProduct

A recommended product with complete display data.

SectionProductVariant

SectionProductOption

SectionTrack

Attribution payload linking a glood:section:* event to a specific section render.

FetchSectionsOptions

Options for fetchRecommendationSections().

GloodApiError

Error thrown when the sections API responds with a non-2xx status.
Usage:

Headless API Types

The headless API is version-aware. A v3 client uses the full suite (/init, /sections, /events, and the recommendations variants); a v2 client is legacy and only supports recommendations, authenticating by shop header alone (no bearer token).

ApiVersion

Headless API version selector. Defaults to 3.

HeadlessRequestOptions

Options passed as the first argument to every standalone headless function (server loaders / advanced usage).

InitParams

Parameters for the v3 session init call.

InitResponse

Response from POST /api/storefront/v3/headless/init. Exposed via the useGloodInit() hook. Always null for v2 clients (init is a v3-only endpoint).

HeadlessEventChannel

Channel a headless event originates from. Defaults to 'hydrogen'.

HeadlessEventParams

Parameters for sending an analytics/attribution event to the versioned events API. On a v3 client this posts to POST /api/storefront/v3/headless/events.

HeadlessEventResponse

Response from the events API.

RecommendationView

Shape of items returned by a recommendation query.

RecommendedProduct

A product returned in the product_details view — same shape as SectionProduct.

RecommendedProductRef

A product returned in the product_ids view.

RecommendedItem

A recommended item — either a full product or a product id reference, depending on the query’s view.

RecommendationQuery

A single query in a multi-query v3 recommendations request.

RecommendationsParams

Parameters for the v3 recommendations endpoint (POST /api/storefront/v3/headless/recommendations).

RecommendationsResponse

Response from the v3 recommendations endpoint. Results are keyed by each query’s id.

V2RecommendationsParams

Parameters for the legacy v2 recommendations endpoint (POST /api/storefront/v2/headless/recommendations, similar_products only).

V2RecommendationsResponse

Response from the v2 recommendations endpoint. Results are keyed by each query’s id.

AutomaticRecommendationsParams

Parameters for the v3 automatic recommendations endpoint (POST /api/storefront/v3/headless/recommendations/automatic) — single anchor, paginated.

AutomaticRecommendationsResponse

TopStrategy

Strategy for the anchorless top recommendations endpoint. Values are uppercase (they map directly to the backend enum).

TopFacet

Facet dimensions returned by the top recommendations endpoint.

TopRecommendationsParams

Parameters for the v3 top recommendations endpoint (POST /api/storefront/v3/headless/recommendations/top) — anchorless, faceted.

TopRecommendationsResponse

Pixel System Types

PixelEvent

Structure for pixel events in the transmission queue.

PixelPayload

Complete pixel payload sent to Glood endpoints.

Constant Types

AppName

Union type for available app names.
Usage:

EventType

Union type for all supported analytics events.
Usage:

ConsentType

Union type for customer privacy consent types.
Usage:

PageType

Union type of page types accepted by the sections API.
The PAGE_TYPES constant exports the same list as a runtime array.

GloodSectionEventName

Union type of the custom attribution event names.
The SECTION_EVENT_NAMES constant exports the same list as a runtime array.

Type Imports

Import specific types as needed:

Best Practices

1. Use Type-Only Imports

Import types with import type so they’re erased at build time:

2. Use Const Assertions

Use const assertions for consent literals:

See Also