useCheckout(). No context provider is required.
Installation
Checkout-only React app
Use managed mode when the React app does not use the Storefront SDK. Checkout creates and owns the anonymous/logged-in session. Initialize once in a root component and clean up on unmount:src/checkout-bootstrap.tsx
<CheckoutBootstrap /> once near the application root.
React app with Storefront SDK
When@commercengine/storefront is present, managed mode would create a second independent session. Use authMode: "provided" and synchronize tokens in both directions.
Follow React SDK integration for the complete provided-mode pattern: storefront config with onTokensUpdated, session bootstrap, and checkout init and teardown.
For Next.js and TanStack Start, use their dedicated SDK integration pages because the Storefront SDK callback is configured on the framework wrapper rather than inside a SPA session object.
Use the hook
src/components/cart-button.tsx
src/components/add-to-cart-button.tsx
null for products without variants. For products with variants, do not enable the button until the UI resolves a purchasable variantId.
Open checkout directly
quickBuy at initialization. See Configuration.
Hook API
Error and lifecycle handling
Use initialization callbacks for app-level behaviour:isReady is true. Do not initialize checkout in every route component.
Next.js
Use a root Client Component that first callsstorefront.bootstrap(), then initializes checkout in provided mode. Follow Next.js SDK integration; do not use the checkout-only managed-mode example in a Next.js storefront that imports @commercengine/storefront.
Production checklist
React starter implementations
Review both Vite React and React meta-framework starters for complete lifecycle, catalog, and deployment patterns.