How to store and update data using HubSpot React?

I am creating a project in HubSpot React, and I am trying to fetch the CRM API (Contact, Company, Deal, etc.). I read about the data-fetching method for HubSpot React, which only reads data, but I want to store and update the data as well. How can I do that? When I access the API directly, I encounter CORS errors, so is there any way to avoid CORS errors and still store and update the data?

Hey @jay_pinetco

You can’t call the APIs directly from the frontend due to CORS restrictions. To access HubSpot CRM data (Contacts, Companies, Deals, etc.) from a React app in HubSpot. The solution is to use HubSpot Serverless Functions as a secure backend proxy.

Here’s how you can do it:

  1. Creat a HubSpot serverless function to act as a proxy between React and the HubSpot CRM API.
  2. Intead of hitting the CRM API directly, use fetch() in the React app to call the function.
  3. This allows reading, creating, updating, and deleting CRM objects without CORS issues and without exposing sensitive tokens.

Here are some documentation links for HubSpot serverless function:- https://developers.hubspot.com/docs/guides/cms/content/data-driven-content/serverless-functions/overview,

Hoping this will be helpful. Feel free to get back to me if there are any further queries or if you want to clarify any confusions I might have had in understanding your query.

Best Regards,

Himanshu Rauthan