How to prevent losing line items inside cart when using apollo, nextjs with SSR?

How to prevent losing line items inside cart when using apollo, nextjs with SSR?

frostmedia
Visitor
1 0 0

I am not sure the best way to ask this but I will give it a shot and hopefully have someone steer me in the right direction.

 

I currently am building a headless Shopify store using NextJS and Apollo for fetching data. I was able to create a single product page for each product using NextJS which uses dynamic routing using the product's handle. I was able to code up the "Add to cart" button which will add the product as a line item inside the shopping cart menu that pops up when product is added. When I go to the home page, the products remain in the cart. If I click on any of the products in my home page (which leads to their own single product page), the products inside my cart dissappear. 

 

How can I make the products inside my cart persist? I have all my apollo useMutation inside the single product page along (with the dynamic routing using the product's handle). 

Replies 0 (0)