Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Correct way to handle user accounts in my Headless app

Correct way to handle user accounts in my Headless app

FlorianWalther
Shopify Partner
3 0 1

I use Next.js together with the Headless app and React-Hydrogen to build a Shopify storefront website.

 

React Hydrogen manages the cart automatically, by storing the cart id in local storage.

 

If the user clears their local storage, this cart is gone. I want to provide a way for users to log in and keep their cart permanently.

 

My first idea was to use my implement authentication solution, store the user accounts in my own DB, and store the cart id in the user table.

 

But there is also Customer Account API and I'm not sure if that would be a better choice for my use case. Can someone enlighten me?

Reply 1 (1)

SBD_
Shopify Staff
1831 273 423

Hey @FlorianWalther 

 

That's a planned feature for Customer Account API but it's not quite ready yet. You'll have to roll your own solution. Keep in mind cart IDs expire after 10 days. Good luck!

Scott | Developer Advocate @ Shopify