@usethrottle/checkout-react
    Preparing search index...

    Function useCartSession

    • React hook for backend-less cart ownership. Wraps CartSessionClient: creates the Throttle cart lazily on the first addItem (so empty carts aren't created on every page load), persists the session id to localStorage, and resumes it on the next visit. Mutations update reactive cart state.

      const cart = useCartSession({ applicationId, environmentId, quoteToken });
      <button onClick={() => cart.addItem({ name: 'Widget', unitPrice: 2999, quantity: 1 })}>Add</button>
      <button onClick={async () => {
      const { checkoutUrl } = await cart.checkout({ returnUrl, cancelUrl });
      window.location.href = checkoutUrl;
      }}>Checkout</button>

      Parameters

      Returns UseCartSessionResult