Skip to content
Kitenzo Headless is invite-only. To enable it on your store, email support@kitenzo.com.

@kitenzo/react

v0.4.0 · published

React bindings. Re-exports everything in @kitenzo/core and adds a provider, hooks and the BundleEmbed component.

Terminal window
npm install @kitenzo/react
  • Depends on: @kitenzo/core.
  • Peer deps: react >= 18, react-dom >= 18. Optional @shopify/hydrogen-react >= 2024.0.0 (only needed for the /hydrogen subpath).
ExportKindDoc
KitenzoProvidercomponentProvider & client. Accepts apiKey, baseUrl, apiVersion, countryCode.
useKitenzohookReturns the KitenzoClient.
useSettingshookReturns ShopSettings | null.
ExportReturnsDoc
useBundles{ bundles, isLoading, error, refetch }Hooks
useBundle{ bundle, isLoading, error, refetch }Hooks
useBundleBuilderbuilder state + methods (incl. isSatisfied, conditions)Hooks
useBundlePriceprice fields (raw + formatted; market-aware)Hooks
useBundleCart{ addBundleToCart, isLoading, error, lastResult } — submit onlyHooks
useBundleAjaxCartfull add-to-cart flow over the theme’s AJAX cartHooks
useSellingPlansubscription purchase-option state (plans, selectPlan, cartLineOptions)Hooks
ExportKindDoc
BundleEmbedcomponentReact — BundleEmbed

Bindings for carts driven by @shopify/hydrogen-react live behind a subpath, so importing @kitenzo/react pulls in none of that optional peer dependency:

import { KitenzoShopifyProvider, useStorefrontBundleCart } from '@kitenzo/react/hydrogen';
ExportKindPurpose
useStorefrontBundleCarthookThe same add-to-cart flow contract as useBundleAjaxCart, for a Storefront-API cart. Needs a <CartProvider> ancestor. Handles hydrogen-react’s silent mutation drops, orders the _bundles write after the lines land, and gates isAdded on it.
KitenzoShopifyProvidercomponentA ShopifyProvider wrapper that degrades gracefully on blank storeDomain / storefrontToken instead of white-screening.

All of @kitenzo/core is available from @kitenzo/react, so a React app installs one package:

import {
KitenzoProvider, useBundle, useBundleBuilder, useBundlePrice, useBundleCart, BundleEmbed,
KitenzoClient, createBundleBuilder, addBundleToCart, buildCartPayload,
calculatePrice, formatMoney, formatCurrency, getSectionLimits, getBundleLimits, UNBOUNDED,
} from '@kitenzo/react';

Plus every TypeScript type.