How to add server-side code (Node.js) on HubSpot

Hi there,

I’m creating a cancel flow page on my website.

To include a cancel form by Churnkey platform on the page, I added HTML code.

As a second step, I need to add node.js code as below to implement server-side verification.

const crypto = require(“crypto”); const API_KEY = “CK_SECRET”;

const user_hash = crypto.createHmac( “sha256”, API_KEY ).update(STRIPE_CUSTOMER_ID).digest(“hex”);

// Send to front-end

However, I have no idea where I need to add the code.

I appreciate any help provided.
Best regards,
Hiss

Hi @Hiss,

So, HubSpot doesn’t natively support server-side code like Node.js since it’s a client-side CMS platform. That being said, you’ve got a few options to make this work.

You’ll need to run that Node.js code on an external server (like AWS Lambda, Heroku, or your own server). Once the verification is done, you can send the response back to your HubSpot page using an API call.

If you’re using HubSpot CMS Enterprise, you can use their serverless functions feature. This lets you run backend code directly in HubSpot. Check out their serverless functions documentation.

Once you have your verification logic running on the external server, send the user_hash back to your HubSpot page using AJAX, and then embed it into the frontend.

I hope it helps, let me know if you need to talk!

Khushboo Pokhriyal

Growth & Operations

GroRapid Labs

LinkedIn | 9315044754 | Email | Website

Thanks, Khushboo!

By following the quick start document below, I could be able to edit CSS in the test page.

https://developers.hubspot.com/docs/cms/guides/getting-started?hsCtaTracking=28bfd0e9-ec05-48a5-b069-ce20015f54ac%7Cc66b91fb-14b1-4c35-ab0d-7e4af8000592

For the next step, I need to edit the front end and back end on a specific page in my website. However, I have no clue how to edit the front (HTML) and back end (Node.js) functions on the specific page. Appreciate if you give me instructions.

Hiss

Hi @Hiss ,

In 2025, HubSpot pages don’t run raw Node.js; you either use a small external service or HubSpot’s serverless functions. Since you only need to HMAC the Stripe customer ID for Churnkey, the clean native path is a serverless function: create a project, add a serverless function that computes user_hash, deploy, then call that endpoint from your page/module and pass the result into the embedded script

(Serverless functions for the CMS - HubSpot docs )

The quickstart shows the exact structure, including where the function file lives and how to expose the endpoint (Get started with serverless functions - HubSpot docs )

If you decide to host this externally, Heroku isn’t a great fit anymore. The free and low-tier dynos tend to sleep, IP addresses rotate, and callbacks can silently fail exactly the kind of fragility you don’t want when verifying Stripe requests.

Even with paid dynos, you’re still left managing uptime, scaling, and monitoring yourself. By contrast, Stacksync removes that operational burden: it runs your integrations on stable infrastructure, handles auth rotation, retries, and event logging automatically, and guarantees real-time two-way sync between HubSpot and your source system. That way, your cancel flow verification stays reliable without you needing to babysit servers or rebuild plumbing when data scales.