Connecting Commerce js to MySql database

184 Views Asked by At

Maybe I'm getting the concept wrong of Commerce js, more specifically about a headless application, that from what I've read is the separation of frontend and backend.

I'm starting to learn Commerce js and using it with React. If I wanted to have my own database in MySQL lets say, because I want to have data of the carts that had been created, the orders that were placed, among other things; how would I go about to do this, since whenever I perform an action I'm using Commerce js API?

1

There are 1 best solutions below

0
scrowler On

Commerce.js is a SaaS (software-as-a-service) product. The storage of data you're referring to (carts, orders, products, etc) is all handled by Commerce.js and the Chec API, so there is no need to connect your own MySQL database.

If you want to synchronise your information from your Commerce.js account into your own database, you can do so by creating webhooks that fire on certain events in the system, such as orders.create, products.update, etc. You can then use the webhook handlers to update your external database. This is useful for extending the capability of the Commerce.js platform, e.g. connecting to an external CRM for customer management, a CMS for extra product information, etc.