Skip to main content

CartLineProvider

The CartLineProvider component creates a context for using a cart line.

Example code

import {CartLineProvider, useCart} from '@shopify/hydrogen';

export function App() {
const {lines} = useCart();

return lines.map((line) => {
return (
<CartLineProvider key={line.id} line={line}>
{/* Your JSX */}
</CartLineProvider>
);
});
}

Props

NameTypeDescription
childrenReactNodeAny ReactNode elements.
lineCart['lines'][1]A cart line object.

Component type

The CartLineProvider component is a client component, which means that it renders on the client. For more information about component types, refer to React Server Components.