<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Custom CMS React Module with business logic in CMS Development</title>
    <link>https://community.hubspot.com/t5/CMS-Development/Custom-CMS-React-Module-with-business-logic/m-p/1210357#M44277</link>
    <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/999817"&gt;@VSengul&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lets start with the first check. Did you put your function where you want to use useState in a React Island?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You need to put the interactive bits in a React Island and render that island from your module. Otherwise the component renders server-side only and never hydrates, so your click handler won’t fire in local dev or on a deployed page.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 09 Oct 2025 13:28:41 GMT</pubDate>
    <dc:creator>BelBarakat</dc:creator>
    <dc:date>2025-10-09T13:28:41Z</dc:date>
    <item>
      <title>Custom CMS React Module with business logic</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Custom-CMS-React-Module-with-business-logic/m-p/1210215#M44275</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hello,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;We are trying to create a custom module to use in CMS. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;We need a page to collect the user information and verify it against the information on a contact. If there is such a contact, we need to display a payment page.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="VSengul_0-1759997808732.png" style="width: 400px;"&gt;&lt;img src="https://community.hubspot.com/t5/image/serverpage/image-id/158110iD3A1B7B5A3523E71/image-size/medium?v=v2&amp;amp;px=400" role="button" title="VSengul_0-1759997808732.png" alt="VSengul_0-1759997808732.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;When the user clicks the "Verify" button, it will call a serverless function that will query HubSpot contacts. The function will return true if there is a matching contact, and a payment page will be displayed.&lt;/P&gt;&lt;P&gt;1- I try to test it in my local dev server by putting a simple console print for the button click event, but it doesn't even do that.&lt;/P&gt;&lt;P&gt;2- When I upload the project, I don't see the new module I created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the code for the module.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import { useState } from 'react';
import {
  ModuleFields,
  TextField,
  RichTextField,
  ImageField,
} from '@hubspot/cms-components/fields';
import { RichText } from '@hubspot/cms-components';
import logo from '../../../assets/sprocket.svg';
import styles from '../../../styles/contributions.module.css';

export function Component({ fieldValues, hublParameters }) {
  const { src, alt, width, height } = fieldValues.logo;
  const { brandColors } = hublParameters;

  const [firstName, setFirstName] = useState('');
  const [lastName, setLastName] = useState('');
  const [memberId, setMemberId] = useState('');
  const [postcode, setPostcode] = useState('');

  const verifyMember = () =&amp;gt; {
    console.log('Verifying member...');
console.log(
              `Thank you ${firstName} ${lastName} for your submission! We will be in touch if we need to verify your member ID: ${memberId} and postcode: ${postcode}.`
            )
  }
  return (
    &amp;lt;div
      className={styles.wrapper}
      style={{
        backgroundColor: brandColors?.color,
        opacity: brandColors?.opacity,
      }}
    &amp;gt;
      &amp;lt;img src={src} alt={alt} width={width} height={height} /&amp;gt;
      &amp;lt;h1&amp;gt;{fieldValues.headline}&amp;lt;/h1&amp;gt;
      &amp;lt;div className={styles.buttons}&amp;gt;
        &amp;lt;input
          name="text"
          placeholder="First Name"
          value={firstName}
          onChange={(e) =&amp;gt; setFirstName(e.target.value)}
        /&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div className={styles.buttons}&amp;gt;
        &amp;lt;input
          name="text"
          placeholder="Last Name"
          value={lastName}
          onChange={(e) =&amp;gt; setLastName(e.target.value)}
        /&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div className={styles.buttons}&amp;gt;
        &amp;lt;input
          name="text"
          placeholder="Member ID"
          value={memberId}
          onChange={(e) =&amp;gt; setMemberId(e.target.value)}
        /&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div className={styles.buttons}&amp;gt;
        &amp;lt;input
          name="text"
          placeholder="Postcode"
          value={postcode}
          onChange={(e) =&amp;gt; setPostcode(e.target.value)}
        /&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;div className={styles.buttons}&amp;gt;
        &amp;lt;button 
          onClick={verifyMember} &amp;gt;Verify&amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  );
}

const richTextFieldDefaultValue = `
  &amp;lt;div&amp;gt;
    &amp;lt;div&amp;gt;
      &amp;lt;span&amp;gt;
        Deploy to your theme by running &amp;lt;pre&amp;gt;npm run deploy&amp;lt;/pre&amp;gt; from the root directory
      &amp;lt;/span&amp;gt;
      &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
`;

export const fields = (
  &amp;lt;ModuleFields&amp;gt;
    &amp;lt;ImageField
      name="logo"
      label="Logo"
      default={{ src: logo, height: 100, alt: 'HubSpot logo' }}
      resizable={true}
    /&amp;gt;
    &amp;lt;TextField
      name="headline"
      label="Headline"
      default="Getting Started with CMS React"
    /&amp;gt;
    &amp;lt;RichTextField
      name="gettingStarted"
      label="Getting Started"
      default={richTextFieldDefaultValue}
    /&amp;gt;
  &amp;lt;/ModuleFields&amp;gt;
);

export const meta = {
  label: 'Contributions',
};&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I appreciate any help.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2025 08:21:48 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Custom-CMS-React-Module-with-business-logic/m-p/1210215#M44275</guid>
      <dc:creator>VSengul</dc:creator>
      <dc:date>2025-10-09T08:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: Custom CMS React Module with business logic</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Custom-CMS-React-Module-with-business-logic/m-p/1210254#M44276</link>
      <description>&lt;P&gt;Hi &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/999817"&gt;@VSengul&lt;/a&gt;&lt;/SPAN&gt; and welcome, it's a pleasure to have you here!&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for sharing your approach and questions around building a custom React module for HubSpot CMS on the HubSpot Community.&lt;BR /&gt;&lt;BR /&gt;I'd love to put you in touch with our Top Experts: Hi &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/115766"&gt;@nickdeckerdevs1&lt;/a&gt;&lt;/SPAN&gt;, &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/92197"&gt;@albertsg&lt;/a&gt;&lt;/SPAN&gt; and &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/776255"&gt;@BelBarakat&lt;/a&gt;&lt;/SPAN&gt; do you have suggestions to help &lt;SPAN style="background: var(--ck-color-mention-background); color: var(--ck-color-mention-text);"&gt;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/999817"&gt;@VSengul&lt;/a&gt;&lt;/SPAN&gt;, please?&lt;BR /&gt;&lt;BR /&gt;Have a wonderful day and thanks so much!&lt;BR /&gt;Bérangère&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2025 09:58:26 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Custom-CMS-React-Module-with-business-logic/m-p/1210254#M44276</guid>
      <dc:creator>BérangèreL</dc:creator>
      <dc:date>2025-10-09T09:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: Custom CMS React Module with business logic</title>
      <link>https://community.hubspot.com/t5/CMS-Development/Custom-CMS-React-Module-with-business-logic/m-p/1210357#M44277</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.hubspot.com/t5/user/viewprofilepage/user-id/999817"&gt;@VSengul&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Lets start with the first check. Did you put your function where you want to use useState in a React Island?&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You need to put the interactive bits in a React Island and render that island from your module. Otherwise the component renders server-side only and never hydrates, so your click handler won’t fire in local dev or on a deployed page.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2025 13:28:41 GMT</pubDate>
      <guid>https://community.hubspot.com/t5/CMS-Development/Custom-CMS-React-Module-with-business-logic/m-p/1210357#M44277</guid>
      <dc:creator>BelBarakat</dc:creator>
      <dc:date>2025-10-09T13:28:41Z</dc:date>
    </item>
  </channel>
</rss>

