@shopify/hydrogen 2026.4.1 → 2026.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode, ComponentType, ScriptHTMLAttributes, FC, ForwardRefExoticComponent, RefAttributes, ComponentProps } from 'react';
3
- import { BuyerInput, CountryCode as CountryCode$1, LanguageCode as LanguageCode$1, VisitorConsent as VisitorConsent$1, CartInput, CartLineInput, CartLineUpdateInput, CartBuyerIdentityInput, CartSelectedDeliveryOptionInput, AttributeInput, Scalars, CartSelectableAddressInput, CartSelectableAddressUpdateInput, Cart, CartMetafieldsSetInput, CartUserError, MetafieldsSetUserError, MetafieldDeleteUserError, CartWarning, Product, ProductVariant, CartLine, ComponentizableCartLine, CurrencyCode, PageInfo, Maybe, ProductOptionValue, ProductOption, ProductVariantConnection, SelectedOptionInput } from '@shopify/hydrogen-react/storefront-api-types';
3
+ import { BuyerInput, Cart, CountryCode as CountryCode$1, LanguageCode as LanguageCode$1, VisitorConsent as VisitorConsent$1, CartInput, CartLineInput, CartLineUpdateInput, CartBuyerIdentityInput, CartSelectedDeliveryOptionInput, AttributeInput, Scalars, CartSelectableAddressInput, CartSelectableAddressUpdateInput, CartMetafieldsSetInput, CartUserError, MetafieldsSetUserError, MetafieldDeleteUserError, CartWarning, Product, ProductVariant, CartLine, ComponentizableCartLine, CurrencyCode, PageInfo, Maybe, ProductOptionValue, ProductOption, ProductVariantConnection, SelectedOptionInput } from '@shopify/hydrogen-react/storefront-api-types';
4
4
  import { createStorefrontClient as createStorefrontClient$1, StorefrontClientProps, RichText as RichText$1, ShopPayButton as ShopPayButton$1 } from '@shopify/hydrogen-react';
5
5
  export { AnalyticsEventName, AnalyticsPageType, ClientBrowserParameters, ExternalVideo, IMAGE_FRAGMENT, Image, MappedProductOptions, MediaFile, ModelViewer, Money, ParsedMetafields, ShopifyAnalytics as SendShopifyAnalyticsEvent, ShopifyAddToCart, ShopifyAddToCartPayload, ShopifyAnalyticsPayload, ShopifyAnalyticsProduct, ShopifyCookies, ShopifyPageView, ShopifyPageViewPayload, ShopifySalesChannel, StorefrontApiResponse, StorefrontApiResponseError, StorefrontApiResponseOk, StorefrontApiResponseOkPartial, StorefrontApiResponsePartial, Video, customerAccountApiCustomScalars, decodeEncodedVariant, flattenConnection, getAdjacentAndFirstAvailableVariants, getClientBrowserParameters, getProductOptions, getShopifyCookies, getTrackingValues, isOptionValueCombinationInEncodedVariant, mapSelectedProductOptionToObject, parseGid, parseMetafield, sendShopifyAnalytics, storefrontApiCustomScalars, useLoadScript, useMoney, useSelectedOptionInUrlParam, useShopifyCookies } from '@shopify/hydrogen-react';
6
6
  import { LanguageCode, CountryCode } from '@shopify/hydrogen-react/customer-account-api-types';
@@ -1077,7 +1077,7 @@ type CustomerAccountOptions = {
1077
1077
  useCustomAuthDomain?: boolean;
1078
1078
  };
1079
1079
 
1080
- type CartGetProps = {
1080
+ type CartGetProps<TExtraVariables = {}> = {
1081
1081
  /**
1082
1082
  * The cart ID.
1083
1083
  * @default cart.getCartId();
@@ -1112,8 +1112,8 @@ type CartGetProps = {
1112
1112
  * When provided, consent is encoded into the cart's checkoutUrl via the _cs parameter.
1113
1113
  */
1114
1114
  visitorConsent?: VisitorConsent$1;
1115
- };
1116
- type CartGetFunction = (cartInput?: CartGetProps) => Promise<CartReturn | null>;
1115
+ } & TExtraVariables;
1116
+ type CartGetFunction<TCart = Cart, TExtraVariables = {}> = (cartInput?: CartGetProps<TExtraVariables>) => Promise<CartReturn<TCart> | null>;
1117
1117
  type CartGetOptions = CartQueryOptions & {
1118
1118
  /**
1119
1119
  * The customer account client instance created by [`createCustomerAccountClient`](docs/api/hydrogen/latest/utilities/createcustomeraccountclient).
@@ -1121,43 +1121,43 @@ type CartGetOptions = CartQueryOptions & {
1121
1121
  customerAccount?: CustomerAccount;
1122
1122
  };
1123
1123
  /** @publicDocs */
1124
- declare function cartGetDefault({ storefront, customerAccount, getCartId, cartFragment, }: CartGetOptions): CartGetFunction;
1124
+ declare function cartGetDefault<TCart = Cart, TExtraVariables = {}>({ storefront, customerAccount, getCartId, cartFragment, }: CartGetOptions): CartGetFunction<TCart, TExtraVariables>;
1125
1125
 
1126
- type CartCreateFunction = (input: CartInput, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1126
+ type CartCreateFunction<TCart = CartQueryDataReturn['cart']> = (input: CartInput, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1127
1127
  /** @publicDocs */
1128
- declare function cartCreateDefault(options: CartQueryOptions): CartCreateFunction;
1128
+ declare function cartCreateDefault<TCart = CartQueryDataReturn['cart']>(options: CartQueryOptions): CartCreateFunction<TCart>;
1129
1129
 
1130
- type CartLinesAddFunction = (lines: Array<CartLineInput>, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1130
+ type CartLinesAddFunction<TCart = CartQueryDataReturn['cart']> = (lines: Array<CartLineInput>, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1131
1131
  /** @publicDocs */
1132
- declare function cartLinesAddDefault(options: CartQueryOptions): CartLinesAddFunction;
1132
+ declare function cartLinesAddDefault<TCart = CartQueryDataReturn['cart']>(options: CartQueryOptions): CartLinesAddFunction<TCart>;
1133
1133
 
1134
- type CartLinesUpdateFunction = (lines: CartLineUpdateInput[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1134
+ type CartLinesUpdateFunction<TCart = CartQueryDataReturn['cart']> = (lines: CartLineUpdateInput[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1135
1135
  /** @publicDocs */
1136
- declare function cartLinesUpdateDefault(options: CartQueryOptions): CartLinesUpdateFunction;
1136
+ declare function cartLinesUpdateDefault<TCart = CartQueryDataReturn['cart']>(options: CartQueryOptions): CartLinesUpdateFunction<TCart>;
1137
1137
 
1138
- type CartLinesRemoveFunction = (lineIds: string[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1138
+ type CartLinesRemoveFunction<TCart = CartQueryDataReturn['cart']> = (lineIds: string[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1139
1139
  /** @publicDocs */
1140
- declare function cartLinesRemoveDefault(options: CartQueryOptions): CartLinesRemoveFunction;
1140
+ declare function cartLinesRemoveDefault<TCart = CartQueryDataReturn['cart']>(options: CartQueryOptions): CartLinesRemoveFunction<TCart>;
1141
1141
 
1142
- type CartDiscountCodesUpdateFunction = (discountCodes: string[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1142
+ type CartDiscountCodesUpdateFunction<TCart = CartQueryDataReturn['cart']> = (discountCodes: string[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1143
1143
  /** @publicDocs */
1144
- declare function cartDiscountCodesUpdateDefault(options: CartQueryOptions): CartDiscountCodesUpdateFunction;
1144
+ declare function cartDiscountCodesUpdateDefault<TCart = CartQueryDataReturn['cart']>(options: CartQueryOptions): CartDiscountCodesUpdateFunction<TCart>;
1145
1145
 
1146
- type CartBuyerIdentityUpdateFunction = (buyerIdentity: CartBuyerIdentityInput, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1146
+ type CartBuyerIdentityUpdateFunction<TCart = CartQueryDataReturn['cart']> = (buyerIdentity: CartBuyerIdentityInput, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1147
1147
  /** @publicDocs */
1148
- declare function cartBuyerIdentityUpdateDefault(options: CartQueryOptions): CartBuyerIdentityUpdateFunction;
1148
+ declare function cartBuyerIdentityUpdateDefault<TCart = CartQueryDataReturn['cart']>(options: CartQueryOptions): CartBuyerIdentityUpdateFunction<TCart>;
1149
1149
 
1150
- type CartNoteUpdateFunction = (note: string, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1150
+ type CartNoteUpdateFunction<TCart = CartQueryDataReturn['cart']> = (note: string, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1151
1151
  /** @publicDocs */
1152
- declare function cartNoteUpdateDefault(options: CartQueryOptions): CartNoteUpdateFunction;
1152
+ declare function cartNoteUpdateDefault<TCart = CartQueryDataReturn['cart']>(options: CartQueryOptions): CartNoteUpdateFunction<TCart>;
1153
1153
 
1154
- type CartSelectedDeliveryOptionsUpdateFunction = (selectedDeliveryOptions: CartSelectedDeliveryOptionInput[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1154
+ type CartSelectedDeliveryOptionsUpdateFunction<TCart = CartQueryDataReturn['cart']> = (selectedDeliveryOptions: CartSelectedDeliveryOptionInput[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1155
1155
  /** @publicDocs */
1156
- declare function cartSelectedDeliveryOptionsUpdateDefault(options: CartQueryOptions): CartSelectedDeliveryOptionsUpdateFunction;
1156
+ declare function cartSelectedDeliveryOptionsUpdateDefault<TCart = CartQueryDataReturn['cart']>(options: CartQueryOptions): CartSelectedDeliveryOptionsUpdateFunction<TCart>;
1157
1157
 
1158
- type CartAttributesUpdateFunction = (attributes: AttributeInput[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1158
+ type CartAttributesUpdateFunction<TCart = CartQueryDataReturn['cart']> = (attributes: AttributeInput[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1159
1159
  /** @publicDocs */
1160
- declare function cartAttributesUpdateDefault(options: CartQueryOptions): CartAttributesUpdateFunction;
1160
+ declare function cartAttributesUpdateDefault<TCart = CartQueryDataReturn['cart']>(options: CartQueryOptions): CartAttributesUpdateFunction<TCart>;
1161
1161
 
1162
1162
  type CartMetafieldsSetFunction = (metafields: MetafieldWithoutOwnerId[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1163
1163
  /** @publicDocs */
@@ -1167,7 +1167,7 @@ type CartMetafieldDeleteFunction = (key: Scalars['String']['input'], optionalPar
1167
1167
  /** @publicDocs */
1168
1168
  declare function cartMetafieldDeleteDefault(options: CartQueryOptions): CartMetafieldDeleteFunction;
1169
1169
 
1170
- type CartGiftCardCodesUpdateFunction = (giftCardCodes: string[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1170
+ type CartGiftCardCodesUpdateFunction<TCart = CartQueryDataReturn['cart']> = (giftCardCodes: string[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1171
1171
  /**
1172
1172
  * Updates (replaces) gift card codes in the cart.
1173
1173
  *
@@ -1181,9 +1181,9 @@ type CartGiftCardCodesUpdateFunction = (giftCardCodes: string[], optionalParams?
1181
1181
  * await updateGiftCardCodes(['SUMMER2025', 'WELCOME10']);
1182
1182
  * @publicDocs
1183
1183
  */
1184
- declare function cartGiftCardCodesUpdateDefault(options: CartQueryOptions): CartGiftCardCodesUpdateFunction;
1184
+ declare function cartGiftCardCodesUpdateDefault<TCart = CartQueryDataReturn['cart']>(options: CartQueryOptions): CartGiftCardCodesUpdateFunction<TCart>;
1185
1185
 
1186
- type CartGiftCardCodesAddFunction = (giftCardCodes: string[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1186
+ type CartGiftCardCodesAddFunction<TCart = CartQueryDataReturn['cart']> = (giftCardCodes: string[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1187
1187
  /**
1188
1188
  * Adds gift card codes to the cart without replacing existing ones.
1189
1189
  *
@@ -1198,127 +1198,19 @@ type CartGiftCardCodesAddFunction = (giftCardCodes: string[], optionalParams?: C
1198
1198
  * await addGiftCardCodes(['SUMMER2025', 'WELCOME10']);
1199
1199
  * @publicDocs
1200
1200
  */
1201
- declare function cartGiftCardCodesAddDefault(options: CartQueryOptions): CartGiftCardCodesAddFunction;
1201
+ declare function cartGiftCardCodesAddDefault<TCart = CartQueryDataReturn['cart']>(options: CartQueryOptions): CartGiftCardCodesAddFunction<TCart>;
1202
1202
 
1203
- type CartGiftCardCodesRemoveFunction = (appliedGiftCardIds: string[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1203
+ type CartGiftCardCodesRemoveFunction<TCart = CartQueryDataReturn['cart']> = (appliedGiftCardIds: string[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1204
1204
  /** @publicDocs */
1205
- declare function cartGiftCardCodesRemoveDefault(options: CartQueryOptions): CartGiftCardCodesRemoveFunction;
1205
+ declare function cartGiftCardCodesRemoveDefault<TCart = CartQueryDataReturn['cart']>(options: CartQueryOptions): CartGiftCardCodesRemoveFunction<TCart>;
1206
1206
 
1207
- type CartDeliveryAddressesAddFunction = (addresses: Array<CartSelectableAddressInput>, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1208
- /**
1209
- * Adds delivery addresses to the cart.
1210
- *
1211
- * This function sends a mutation to the storefront API to add one or more delivery addresses to the cart.
1212
- * It returns the result of the mutation, including any errors that occurred.
1213
- *
1214
- * @param {CartQueryOptions} options - The options for the cart query, including the storefront API client and cart fragment.
1215
- * @returns {CartDeliveryAddressAddFunction} - A function that takes an array of addresses and optional parameters, and returns the result of the API call.
1216
- *
1217
- * @example
1218
- * const addDeliveryAddresses = cartDeliveryAddressesAddDefault({ storefront, getCartId });
1219
- * const result = await addDeliveryAddresses([
1220
- * {
1221
- * address1: '123 Main St',
1222
- * city: 'Anytown',
1223
- * countryCode: 'US'
1224
- * // other address fields...
1225
- * }
1226
- * ], { someOptionalParam: 'value' }
1227
- * );
1228
- * @publicDocs
1229
- */
1230
- declare function cartDeliveryAddressesAddDefault(options: CartQueryOptions): CartDeliveryAddressesAddFunction;
1207
+ type CartDeliveryAddressesAddFunction<TCart = CartQueryDataReturn['cart']> = (addresses: Array<CartSelectableAddressInput>, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1231
1208
 
1232
- type CartDeliveryAddressesRemoveFunction = (addressIds: Array<Scalars['ID']['input']> | Array<string>, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1233
- /**
1234
- * Removes delivery addresses from the cart.
1235
- *
1236
- * This function sends a mutation to the storefront API to remove one or more delivery addresses from the cart.
1237
- * It returns the result of the mutation, including any errors that occurred.
1238
- *
1239
- * @param {CartQueryOptions} options - The options for the cart query, including the storefront API client and cart fragment.
1240
- * @returns {CartDeliveryAddressRemoveFunction} - A function that takes an array of address IDs and optional parameters, and returns the result of the API call.
1241
- *
1242
- * @example
1243
- * const removeDeliveryAddresses = cartDeliveryAddressesRemoveDefault({ storefront, getCartId });
1244
- * const result = await removeDeliveryAddresses([
1245
- * "gid://shopify/<objectName>/10079785100"
1246
- * ],
1247
- * { someOptionalParam: 'value' });
1248
- * @publicDocs
1249
- */
1250
- declare function cartDeliveryAddressesRemoveDefault(options: CartQueryOptions): CartDeliveryAddressesRemoveFunction;
1209
+ type CartDeliveryAddressesRemoveFunction<TCart = CartQueryDataReturn['cart']> = (addressIds: Array<Scalars['ID']['input']> | Array<string>, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1251
1210
 
1252
- type CartDeliveryAddressesUpdateFunction = (addresses: Array<CartSelectableAddressUpdateInput>, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1253
- /**
1254
- * Updates delivery addresses in the cart.
1255
- *
1256
- * Pass an empty array to clear all delivery addresses from the cart.
1257
- *
1258
- * @param {CartQueryOptions} options - The options for the cart query, including the storefront API client and cart fragment.
1259
- * @returns {CartDeliveryAddressUpdateFunction} - A function that takes an array of addresses and optional parameters, and returns the result of the API call.
1260
- *
1261
- * @example Clear all delivery addresses
1262
- * const updateAddresses = cartDeliveryAddressesUpdateDefault(cartQueryOptions);
1263
- * await updateAddresses([]);
1264
- *
1265
- * @example Update specific delivery addresses
1266
- * const updateAddresses = cartDeliveryAddressesUpdateDefault(cartQueryOptions);
1267
- * await updateAddresses([
1268
- {
1269
- "address": {
1270
- "copyFromCustomerAddressId": "gid://shopify/<objectName>/10079785100",
1271
- "deliveryAddress": {
1272
- "address1": "<your-address1>",
1273
- "address2": "<your-address2>",
1274
- "city": "<your-city>",
1275
- "company": "<your-company>",
1276
- "countryCode": "AC",
1277
- "firstName": "<your-firstName>",
1278
- "lastName": "<your-lastName>",
1279
- "phone": "<your-phone>",
1280
- "provinceCode": "<your-provinceCode>",
1281
- "zip": "<your-zip>"
1282
- }
1283
- },
1284
- "id": "gid://shopify/<objectName>/10079785100",
1285
- "oneTimeUse": true,
1286
- "selected": true,
1287
- "validationStrategy": "COUNTRY_CODE_ONLY"
1288
- }
1289
- ],{ someOptionalParam: 'value' });
1290
- * @publicDocs
1291
- */
1292
- declare function cartDeliveryAddressesUpdateDefault(options: CartQueryOptions): CartDeliveryAddressesUpdateFunction;
1211
+ type CartDeliveryAddressesUpdateFunction<TCart = CartQueryDataReturn['cart']> = (addresses: Array<CartSelectableAddressUpdateInput>, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1293
1212
 
1294
- type CartDeliveryAddressesReplaceFunction = (addresses: Array<CartSelectableAddressInput>, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn>;
1295
- /**
1296
- * Replaces all delivery addresses on the cart.
1297
- *
1298
- * This function sends a mutation to the storefront API to replace all delivery addresses on the cart
1299
- * with the provided addresses. It returns the result of the mutation, including any errors that occurred.
1300
- *
1301
- * @param {CartQueryOptions} options - The options for the cart query, including the storefront API client and cart fragment.
1302
- * @returns {CartDeliveryAddressesReplaceFunction} - A function that takes an array of addresses and optional parameters, and returns the result of the API call.
1303
- *
1304
- * @example
1305
- * const replaceDeliveryAddresses = cartDeliveryAddressesReplaceDefault({ storefront, getCartId });
1306
- * const result = await replaceDeliveryAddresses([
1307
- * {
1308
- * address: {
1309
- * deliveryAddress: {
1310
- * address1: '123 Main St',
1311
- * city: 'Anytown',
1312
- * countryCode: 'US'
1313
- * }
1314
- * },
1315
- * selected: true
1316
- * }
1317
- * ], { someOptionalParam: 'value' }
1318
- * );
1319
- * @publicDocs
1320
- */
1321
- declare function cartDeliveryAddressesReplaceDefault(options: CartQueryOptions): CartDeliveryAddressesReplaceFunction;
1213
+ type CartDeliveryAddressesReplaceFunction<TCart = CartQueryDataReturn['cart']> = (addresses: Array<CartSelectableAddressInput>, optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn<TCart>>;
1322
1214
 
1323
1215
  type CartHandlerOptions = {
1324
1216
  storefront: Storefront;
@@ -1330,26 +1222,26 @@ type CartHandlerOptions = {
1330
1222
  buyerIdentity?: CartBuyerIdentityInput;
1331
1223
  };
1332
1224
  type CustomMethodsBase = Record<string, Function>;
1333
- type CartHandlerOptionsWithCustom<TCustomMethods extends CustomMethodsBase> = CartHandlerOptions & {
1334
- customMethods?: TCustomMethods;
1225
+ type CartHandlerOptionsWithRequiredCustom<TCustomMethods extends CustomMethodsBase> = CartHandlerOptions & {
1226
+ customMethods: TCustomMethods;
1335
1227
  };
1336
- type HydrogenCart = {
1337
- get: ReturnType<typeof cartGetDefault>;
1228
+ type HydrogenCart<TCart = HydrogenCustomCartFragment & Cart, TGetExtraVariables = {}> = {
1229
+ get: CartGetFunction<TCart, TGetExtraVariables>;
1338
1230
  getCartId: () => string | undefined;
1339
1231
  setCartId: (cartId: string) => Headers;
1340
- create: ReturnType<typeof cartCreateDefault>;
1341
- addLines: ReturnType<typeof cartLinesAddDefault>;
1342
- updateLines: ReturnType<typeof cartLinesUpdateDefault>;
1343
- removeLines: ReturnType<typeof cartLinesRemoveDefault>;
1344
- updateDiscountCodes: ReturnType<typeof cartDiscountCodesUpdateDefault>;
1345
- updateGiftCardCodes: ReturnType<typeof cartGiftCardCodesUpdateDefault>;
1346
- addGiftCardCodes: ReturnType<typeof cartGiftCardCodesAddDefault>;
1347
- removeGiftCardCodes: ReturnType<typeof cartGiftCardCodesRemoveDefault>;
1348
- updateBuyerIdentity: ReturnType<typeof cartBuyerIdentityUpdateDefault>;
1349
- updateNote: ReturnType<typeof cartNoteUpdateDefault>;
1350
- updateSelectedDeliveryOption: ReturnType<typeof cartSelectedDeliveryOptionsUpdateDefault>;
1351
- updateAttributes: ReturnType<typeof cartAttributesUpdateDefault>;
1352
- setMetafields: ReturnType<typeof cartMetafieldsSetDefault>;
1232
+ create: CartCreateFunction<TCart>;
1233
+ addLines: CartLinesAddFunction<TCart>;
1234
+ updateLines: CartLinesUpdateFunction<TCart>;
1235
+ removeLines: CartLinesRemoveFunction<TCart>;
1236
+ updateDiscountCodes: CartDiscountCodesUpdateFunction<TCart>;
1237
+ updateGiftCardCodes: CartGiftCardCodesUpdateFunction<TCart>;
1238
+ addGiftCardCodes: CartGiftCardCodesAddFunction<TCart>;
1239
+ removeGiftCardCodes: CartGiftCardCodesRemoveFunction<TCart>;
1240
+ updateBuyerIdentity: CartBuyerIdentityUpdateFunction<TCart>;
1241
+ updateNote: CartNoteUpdateFunction<TCart>;
1242
+ updateSelectedDeliveryOption: CartSelectedDeliveryOptionsUpdateFunction<TCart>;
1243
+ updateAttributes: CartAttributesUpdateFunction<TCart>;
1244
+ setMetafields: (metafields: MetafieldWithoutOwnerId[], optionalParams?: CartOptionalInput) => Promise<CartQueryDataReturn | CartQueryDataReturn<TCart>>;
1353
1245
  deleteMetafield: ReturnType<typeof cartMetafieldDeleteDefault>;
1354
1246
  /**
1355
1247
  * Adds delivery addresses to the cart.
@@ -1372,7 +1264,7 @@ type HydrogenCart = {
1372
1264
  * { someOptionalParam: 'value' }
1373
1265
  * );
1374
1266
  */
1375
- addDeliveryAddresses: ReturnType<typeof cartDeliveryAddressesAddDefault>;
1267
+ addDeliveryAddresses: CartDeliveryAddressesAddFunction<TCart>;
1376
1268
  /**
1377
1269
  * Removes delivery addresses from the cart.
1378
1270
  *
@@ -1388,7 +1280,7 @@ type HydrogenCart = {
1388
1280
  * ],
1389
1281
  * { someOptionalParam: 'value' });
1390
1282
  */
1391
- removeDeliveryAddresses: ReturnType<typeof cartDeliveryAddressesRemoveDefault>;
1283
+ removeDeliveryAddresses: CartDeliveryAddressesRemoveFunction<TCart>;
1392
1284
  /**
1393
1285
  * Updates delivery addresses in the cart.
1394
1286
  *
@@ -1422,7 +1314,7 @@ type HydrogenCart = {
1422
1314
  }
1423
1315
  ],{ someOptionalParam: 'value' });
1424
1316
  */
1425
- updateDeliveryAddresses: ReturnType<typeof cartDeliveryAddressesUpdateDefault>;
1317
+ updateDeliveryAddresses: CartDeliveryAddressesUpdateFunction<TCart>;
1426
1318
  /**
1427
1319
  * Replaces all delivery addresses on the cart.
1428
1320
  *
@@ -1446,12 +1338,13 @@ type HydrogenCart = {
1446
1338
  * }
1447
1339
  * ], { someOptionalParam: 'value' });
1448
1340
  */
1449
- replaceDeliveryAddresses: ReturnType<typeof cartDeliveryAddressesReplaceDefault>;
1341
+ replaceDeliveryAddresses: CartDeliveryAddressesReplaceFunction<TCart>;
1450
1342
  };
1451
- type HydrogenCartCustom<TCustomMethods extends Partial<HydrogenCart> & CustomMethodsBase> = Omit<HydrogenCart, keyof TCustomMethods> & TCustomMethods;
1343
+ type HydrogenCartCustom<TCustomMethods extends CustomMethodsBase, TCart = HydrogenCustomCartFragment & Cart, TGetExtraVariables = {}> = Omit<HydrogenCart<TCart, TGetExtraVariables>, keyof TCustomMethods> & TCustomMethods;
1452
1344
  /** @publicDocs */
1453
- declare function createCartHandler(options: CartHandlerOptions): HydrogenCart;
1454
- declare function createCartHandler<TCustomMethods extends CustomMethodsBase>(options: CartHandlerOptionsWithCustom<TCustomMethods>): HydrogenCartCustom<TCustomMethods>;
1345
+ declare function createCartHandler<TCustomMethods extends CustomMethodsBase>(options: CartHandlerOptionsWithRequiredCustom<TCustomMethods>): HydrogenCartCustom<TCustomMethods>;
1346
+ declare function createCartHandler<TCart = HydrogenCustomCartFragment & Cart, TGetExtraVariables = {}>(options: CartHandlerOptions): HydrogenCart<TCart, TGetExtraVariables>;
1347
+ declare function createCartHandler<TCart, TGetExtraVariables, TCustomMethods extends CustomMethodsBase>(options: CartHandlerOptionsWithRequiredCustom<TCustomMethods>): HydrogenCartCustom<TCustomMethods, TCart, TGetExtraVariables>;
1455
1348
 
1456
1349
  type RequestEventPayload = {
1457
1350
  url: string;
@@ -1848,6 +1741,29 @@ type StorefrontMutationOptionsForDocs = {
1848
1741
  displayName?: string;
1849
1742
  };
1850
1743
 
1744
+ declare global {
1745
+ /**
1746
+ * Extensible interface for typing cart results with a custom cart fragment.
1747
+ * Augment this interface with your codegen'd fragment type to get full type
1748
+ * safety on every cart operation — whether accessed via `context.cart`,
1749
+ * `createCartHandler`, or `createHydrogenContext`.
1750
+ *
1751
+ * When empty (the default), `HydrogenCustomCartFragment & Cart` collapses
1752
+ * to `Cart`, so existing behaviour is unchanged.
1753
+ *
1754
+ * @example
1755
+ * ```ts
1756
+ * // In app/lib/context.ts
1757
+ * import type {CartApiQueryFragment} from 'storefrontapi.generated';
1758
+ *
1759
+ * declare global {
1760
+ * interface HydrogenCustomCartFragment extends CartApiQueryFragment {}
1761
+ * }
1762
+ * ```
1763
+ */
1764
+ interface HydrogenCustomCartFragment {
1765
+ }
1766
+ }
1851
1767
  type CartOptionalInput = {
1852
1768
  /**
1853
1769
  * The cart id.
@@ -1899,18 +1815,18 @@ type CartQueryOptions = {
1899
1815
  */
1900
1816
  customerAccount?: CustomerAccount;
1901
1817
  };
1902
- type CartReturn = Cart & {
1818
+ type CartReturn<TCart = Cart> = TCart & {
1903
1819
  errors?: StorefrontApiErrors;
1904
1820
  };
1905
- type CartQueryData = {
1906
- cart: Cart;
1821
+ type CartQueryData<TCart = Cart> = {
1822
+ cart: TCart;
1907
1823
  userErrors?: CartUserError[] | MetafieldsSetUserError[] | MetafieldDeleteUserError[];
1908
1824
  warnings?: CartWarning[];
1909
1825
  };
1910
- type CartQueryDataReturn = CartQueryData & {
1826
+ type CartQueryDataReturn<TCart = Cart> = CartQueryData<TCart> & {
1911
1827
  errors?: StorefrontApiErrors;
1912
1828
  };
1913
- type CartQueryReturn<T> = (requiredParams: T, optionalParams?: CartOptionalInput) => Promise<CartQueryData>;
1829
+ type CartQueryReturn<T, TCart = Cart> = (requiredParams: T, optionalParams?: CartOptionalInput) => Promise<CartQueryData<TCart>>;
1914
1830
 
1915
1831
  declare const AnalyticsEvent: {
1916
1832
  PAGE_VIEWED: "page_viewed";
@@ -2927,12 +2843,12 @@ type GetSelectedProductOptions = (request: Request) => SelectedOptionInput[];
2927
2843
  declare const getSelectedProductOptions: GetSelectedProductOptions;
2928
2844
 
2929
2845
  /**
2930
- * Official Hydrogen Preset for React Router 7.12.x
2846
+ * Official Hydrogen Preset for React Router 7.16.x
2931
2847
  *
2932
2848
  * Provides optimal React Router configuration for Hydrogen applications on Oxygen.
2933
2849
  * Enables validated performance optimizations while ensuring CLI compatibility.
2934
2850
  *
2935
- * React Router 7.12.x Feature Support Matrix for Hydrogen 2025.7.0
2851
+ * React Router 7.16.x Feature Support Matrix for Hydrogen 2025.7.0
2936
2852
  *
2937
2853
  * +----------------------------------+----------+----------------------------------+
2938
2854
  * | Feature | Status | Notes |
@@ -2960,7 +2876,7 @@ declare const getSelectedProductOptions: GetSelectedProductOptions;
2960
2876
  * | prerender: ['/routes'] | Blocked | Plugin incompatibility |
2961
2877
  * | serverBundles: () => {} | Blocked | Manifest incompatibility |
2962
2878
  * | buildEnd: () => {} | Blocked | CLI bypasses hook execution |
2963
- * | unstable_subResourceIntegrity | Blocked | CSP nonce/hash conflict |
2879
+ * | subResourceIntegrity | Blocked | CSP nonce/hash conflict |
2964
2880
  * | v8_viteEnvironmentApi | Blocked | CLI fallback detection used |
2965
2881
  * +----------------------------------+----------+----------------------------------+
2966
2882
  *