Headless API
SDK reference
hydrogen
routes
joy-products

routes/joy-products

Interfaces

JoyAjaxProduct

A product in the shape of Shopify's /products/{handle}.js — integer cents, flat image URLs. See toAjaxProduct for why this shape and not the raw GraphQL one.

Properties

compare_at_price
compare_at_price: number | null;
featured_image
featured_image: string;
handle
handle: string;
id
id: string;

Numeric id split out of the gid (gid://shopify/Product/123 → "123"), falling back to the whole gid if it carries no numeric segment. The core keys its subscription-offer index by this AND by handle, so the handle key covers either form.

images
images: string[];
price
price: number | null;
title
title: string;
url
url: string;

Always canonical /products/{handle} — see toAjaxProduct.

variants
variants: JoyAjaxVariant[];

JoyAjaxVariant

A variant in the Ajax shape the core extractors read.

Properties

compare_at_price
compare_at_price: number | null;
id
id: string;
price
price: number | null;
sellingPlanAllocations
sellingPlanAllocations: object[];

Flattened per-delivery prices, in cents. The widget core accepts this camelCase spelling and this key, so it needs no change.

perDeliveryPrice
perDeliveryPrice: number;

JoyCollection

One entry of the promoted-collections strip, in the shape the core's loadPromotedCollections hands straight to the component (host/data-port.ts's PromotedCollection).

⚠️ No productCount. The Liquid path reads it from /collections/{handle}.json, but the Storefront API's Collection type exposes no product-count field at all (verified against @shopify/hydrogen-react/storefront.schema.json) and counting via products(first:250) would cost a page fetch per collection for one number. Omitting it is safe: joy-promoted-collections.ts:390 hides the count when it is null, so headless shows the same strip minus that one line.

Properties

handle
handle: string;
id
id: string;

Numeric id split out of the gid, same treatment as JoyAjaxProduct.id.

image?
image?: string;

Featured image URL; absent when the collection has none, so the component draws its monogram fallback.

title
title: string;
url
url: string;

Always canonical /collections/{handle}.


JoyCollectionsResponse

Mode C's payload. Has no products key — the caller reads collections.

Properties

collections
collections: JoyCollection[];

The collections that resolved, in the merchant's configured order. Collections the shop no longer has are dropped, not nulled: this is a curated strip the merchant arranged, so a shorter strip reads better than a hole. Mode A nulls instead because its caller maps results back per handle.


JoyProductsContext

The subset of the Hydrogen route context this handler needs.

Properties

storefront
storefront: JoyProductsStorefront;

JoyProductsLoaderArgs

Structural shape of a Hydrogen/Remix loader's args.

Properties

context
context: JoyProductsContext;
request
request: Request;

JoyProductsResponse

Properties

currencyCode
currencyCode: string | null;

Currency of the returned prices, so the widget formats them with the buyer's symbol rather than the hardcoded 'USD'. null when nothing came back.

handles?
handles?: string[];

Mode A only — the handles actually queried, after the allow-list, the cap and de-duplication. Lets the caller line products up without re-deriving that filtering.

products
products: (JoyAjaxProduct | null)[];

Mode A: one entry per accepted handle, null where the shop has no such product. Mode B: the recommended/fallback products, seed excluded.


JoyProductsStorefront

The subset of a Hydrogen storefront client this route uses.

Methods

query()
query(query, options): Promise<unknown>;
Parameters
ParameterType
querystring
options{ displayName?: string; variables?: Record<string, unknown>; }
options.displayName?string
options.variables?Record<string, unknown>
Returns

Promise<unknown>

Functions

loader()

function loader(__namedParameters): Promise<Response>;

Hydrogen resource-route loader. Always resolves to a Response; never throws.

Parameters

ParameterType
__namedParametersJoyProductsLoaderArgs

Returns

Promise<Response>