10. Cart screen
Show line items, update quantities, and go to checkout.
On this page
In this step, you'll create a cart screen where users can view the items they've added to their cart, adjust quantities, and proceed to checkout.
You'll create the necessary components and utilities first, then implement the cart screen and add it to the navigation.
Add Cart Item Component
First, you'll create a cart item component to display individual items in the cart.
Create the file components/cart-item.tsx with the following content:
tsx
The CartItem component receives the following props:
item: The cart line item to display.currencyCode: The currency code for formatting prices.onUpdateQuantity: Callback to update the quantity of the item.onRemove: Callback to remove the item from the cart.
In the component, you display the item's image, title, variant name, and price. You also provide buttons to adjust the quantity and remove the item from the cart.
Add Cart Screen
Next, you'll implement the cart screen where users can view and manage their cart items.
As mentioned before, you'll have a tab for the cart screen. So, to create the cart screen, create the file app/(drawer)/(tabs)/(cart)/index.tsx with the following content:
tsx
You define the CartScreen component that uses the useCart hook to access the cart state and actions. It handles three main states:
- Loading: Displays a loading indicator while fetching the cart.
- Empty Cart: Displays a message and a button to browse products if the cart is empty.
- Cart with Items: Renders a list of cart items using the
CartItemcomponent, along with cart totals.
You also provide a button to proceed to checkout. Right now, the button does nothing. You'll change it to navigate to the checkout screen later.
Next, you'll add stack navigation for the cart screen.
Create the file app/(drawer)/(tabs)/(cart)/_layout.tsx with the following content:
tsx
You show the cart screen with a header that includes a button to open the drawer navigation.
Add Cart Tab to Navigation
Finally, you'll add the cart tab to the main tab navigator.
In app/(drawer)/(tabs)/_layout.tsx, add the following import at the top of the file:
tsx
Then, in the TabLayout component, add the following before the return statement:
tsx
You access the cart from the cart context to get the number of items in the cart.
Finally, replace the // TODO add cart tab comment in the return statement with the following:
tsx
You add a new tab to the tab navigator for the cart screen. The tab displays a badge with the number of items in the cart.
Test Cart Screen
To test out the cart screen, run your Aiminaabee application and Expo app.
Then, add some products to your cart from the product detail screen. You can open the cart by clicking its tab in the bottom navigation.

You can update an item's quantity or remove an item, and the cart will be updated accordingly.
Next: 11. Checkout