Skip to main content
The cart can be used with Colossal’s hosted checkout or with your own backend and checkout flow.

CartProvider

Wrap your app in CartProvider to manage cart state. It handles cart creation, persistence, and provides actions through context.
component

High-level hooks

Use useCartContext inside CartProvider for the simplest cart integration.
addItem automatically creates a new cart if one doesn’t exist yet. If the stored cart is no longer valid (e.g., it expired), it creates a fresh cart and retries.

Low-level hooks

Direct control over cart mutations, for use outside CartProvider.

Types

CartContext

Returned by useCartContext().
CartContext

SimpleLineItem

Each item in the items array.
SimpleLineItem

Custom storage

The default localStorageCartIds stores cart IDs in localStorage keyed by cart-{storeUid}. To use a different storage mechanism, implement the CartIdStorage interface:

Next steps