Supported products
Supported products
Prerequisites
- The HubSpot CLI installed and authenticated.
- A Revenue Hub Professional or Enterprise account.
- Familiarity with React and CMS React modules.
Download the example project
To get started, download HubSpot’s quote-dev-starter project from GitHub. It contains a working example of a typed React module that pulls quote and CRM data from HubL and hydrates an interactive island on the client. This will also run apostinstall step to install dependencies in src/cms-assets/my-react-assets/.
src/cms-assets/my-react-assets
Globals.d.ts
components/modules/QuoteExampleModule
index.tsx
islands
InteractiveButton.tsx
index.tsx: the module entry point. Exports the ReactComponent,fields,meta, andhublDataTemplate. This is where you define what data the module receives and how it renders.islands/InteractiveButton.tsx: a client-hydrated Island component that adds interactivity to the published quote.Globals.d.ts: type declarations for the project. The@hubspot/quote-dev-sdkpackage provides theQuoteTemplateContexttype used in the module, which gives you compile-time safety against thequoteTemplateContextshape available in HubL.
Review the example module
Module configuration
The module’smeta export sets its label and the content types it supports. Both QUOTE and QUOTE_BLUEPRINT are required.
index.tsx
STYLE tab for appearance options:
index.tsx
Accessing quote data
ThehublDataTemplate export is a HubL string that runs server-side and passes data into your React component via props.hublData. The example uses it to extract specific values from quoteTemplateContext and to fetch data using the crm_object() HubL function:
index.tsx
hublDataTemplate demonstrates a few key patterns:
- Targeted data:
hublDatais built as a specific object with only the values the component needs, rather than passing the entirequoteTemplateContext. This keeps the quote clean by only exposing the properties needed. - Fetching data: the example uses
crm_object()to fetch specific property values (nameanddomain) from the associated company. You can use HubL functions such ascrm_object()andcrm_associations()to fetch data beyond what’s available directly inquoteTemplateContext. - Conditional rendering: within
hublData, theis_in_editorflag is passed to React so that the component can adjust its rendering in the editor context. See Adding client-side interactivity for more information.
Providing fallback data for templates
isQuoteBlueprint is a HubL global variable that is true when the module is rendered inside a quote template rather than an individual quote. Since quote templates are not attached to a real quote, properties like company name will be empty.
The example handles this by substituting placeholder values (e.g., HubSpot) when isQuoteBlueprint is true:
index.tsx
Using quote totals
quoteTemplateContext.quoteTotals contains the calculated totals for the quote, so you can build a custom totals module or a custom line items module that displays totals alongside your line items. Because quoteTotals may not be present on every quote or template, check that it exists before reading from it.
The
QuoteTotals type requires @hubspot/quote-dev-sdk v0.3.0 or later.quoteTotals contains the following properties:
subTotals, discountSubTotals, and taxSubTotals are keyed by billing frequency. Only the frequencies used on the quote are included. The supported billing frequencies are one_time, weekly, biweekly, monthly, quarterly, per_six_months, annually, per_two_years, per_three_years, per_four_years, and per_five_years.
The following example extracts only the values a module needs in hublDataTemplate, rather than passing the full context:
index.tsx
Using tiered line item data
For line items that use tiered pricing,quoteTemplateContext.lineItemTiers contains a summary of how each line item’s price is calculated across its tiers. This is useful when building a custom line items module that shows tier breakdowns.
lineItemTiers is an object keyed by the line item’s object ID (as a string, matching the hs_object_id value on the line item). Line items that don’t use tiered pricing don’t have an entry, so check that an entry exists before reading from it.
Each entry contains the following properties:
Each object in
breakdowns contains the following properties:
The following example renders the tier breakdown for each tiered line item. It passes the line items and tiers to the module’s server-rendered component, not to an island, so that the data isn’t serialized into the published quote’s source code:
index.tsx
The
lineItemTiers type requires @hubspot/quote-dev-sdk v0.3.0 or later.Adding client-side interactivity
React modules use server-side rendering. To add client-side interactivity, you can use islands, which hydrate server-rendered HTML with client-side JavaScript. The example project includes a simple button as an island (InteractiveButton.tsx), which is a standard React component with client-side state:
InteractiveButton.tsx
index.tsx: once as a plain component (for static rendering in the editor), and once with the ?island suffix (for client-side hydration when live):
index.tsx
Passing data props
Any props you pass to anIsland are serialized into the page HTML so the component can hydrate on the client. This means island prop values are visible to anyone who views the source code of the published quote page. Because quote data can include sensitive information such as line item pricing, customer details, and custom CRM properties, you should pass only the specific property values your island needs to render.
For example, to make the quote title available to an island, pass the hs_title string:
index.tsx
quoteTemplateContext as shown below would expose all quote and associated object properties on the rendered page:
index.tsx
Conditional rendering
Don’t render islands in the quote editor. When an island renders in the editor, it causes a full reload of the quote preview (rather than a per-module hot reload), and users will see a change confirmation modal each time they make a change to the quote. To avoid this, the example island checks theisInEditor flag and renders a static version of the button component with an explanatory note instead:
index.tsx
isInEditor flag comes from hublData, where it’s set in hublDataTemplate as is_in_editor.
index.tsx
is_in_previewer variable. This is recommended for modules where the client-side interactivity writes data, as it prevents the quote author from accidentally changing something before publishing.
Rendering for print and PDF
Quotes are web pages that users can save and share as PDFs. When generating a PDF, HubSpot renders the quote with a?print=true query parameter in the URL. You can check for this parameter in island components to skip interactive behavior that doesn’t make sense in a static document.
If buyers can edit your module’s content on a published quote, you also need to tell HubSpot when the PDF is out of date. Learn more about regenerating the quote PDF.
For example, a navigation island that scrolls buyers to sections of the quote should be hidden when printing:
QuoteNav.tsx
@media print CSS media query. For example, to hide a navigation element that only makes sense in the browser:
Control acceptance and payment state
@hubspot/quote-dev-sdk provides two hooks for reading and controlling the live acceptance and payment state of a quote from within a custom module:
Both hooks must be used inside an island component, since they rely on client-side events.
These hooks require
@hubspot/quote-dev-sdk v0.2.0 or later.useQuoteAcceptance
The useQuoteAcceptance hook returns { loading, error, data, control }.
data contains the following:
control exposes enable() and disable({ reason? }). Note that disable() will have no effect when accepted is true or when acceptanceMethod is 'print_and_sign'.
The starter project’s RequiredAgreementModule shows a complete working implementation. The module is split across two component files: a parent index.tsx that detects the editor context and wraps the interactive piece in an Island, and islands/TermsAcceptance.tsx, which contains the hook logic. The island renders a terms checkbox and calls control.disable() or control.enable() based on the buyer’s input:
The
isInEditor prop is passed in from the parent index.tsx, which calls useEditorVariableChecks() to detect the HubSpot page editor context. The guards in useEffect and handleChange prevent the hook from firing during editor previews.useQuotePayment
The useQuotePayment hook returns { loading, error, data, control }.
data contains the following:
control exposes enable() and disable({ reason? }). Note that disable() will have no effect when status is 'PAID' or 'PROCESSING'.
Regenerate the quote PDF
If buyers can change what your module displays on a published quote (for example, by selecting an option or editing a value), the quote’s PDF needs to reflect those changes. Use theuseQuotePdf hook to tell HubSpot when the PDF is out of date, and to find out when buyers can no longer make changes that would affect it.
Like the acceptance and payment hooks, useQuotePdf must be used inside an island component.
The
useQuotePdf hook requires @hubspot/quote-dev-sdk v0.3.0 or later.useQuotePdf hook returns { loading, error, data, actions }.
data contains the following:
actions contains the following:
Call
reportPdfStale() whenever the appearance of your module changes, typically after a buyer edit. You don’t need to regenerate the PDF yourself.
When buyers can change the PDF
A quote’s PDF can’t be regenerated once the quote has been partially or fully accepted.canReportPdfStale reflects this, and is false in the following cases:
- E-signature: at least one signer has signed.
- Clickwrap: the quote has been accepted.
- Print and sign: a sales rep has marked the quote as signed in HubSpot.
- Void quotes: the quote has been voided.
- While loading: the acceptance or quote status is still loading.
data.canReportPdfStale defaults to false, so your module stays disabled rather than briefly appearing interactive. Disable your module’s inputs while loading is true or canReportPdfStale is false.
Example
The following island lets buyers choose whether to include an optional add-on. It disables the checkbox while the quote state loads and after the quote is accepted, and callsreportPdfStale() when the buyer makes a change.
AddOnSelector.tsx
Note that in the above example, the checkbox state would need to be persisted, using a backend database or via a property in HubSpot so the correct state would appear in the PDF.
index.tsx, check the editor and previewer flags before rendering the island:
index.tsx
isInEditorOrPreviewer value comes from hublData, where it’s set in hublDataTemplate:
index.tsx
E-signature usage
If a quote uses e-signatures, regenerating the PDF can count toward your monthly e-signature limit. Regenerating the PDF for download doesn’t use any additional e-signatures. However, after any signer has initiated signing, an edit that causes the PDF to regenerate counts as an additional e-signature. Initiating signing means that a signer has selected the e-signature option to begin the signing process. Edits made before signing is initiated don’t count. Learn more about e-signature limits.Defer PDF capture
Custom coded modules can display a loading state while they fetch the data needed to render. When a quote PDF is being captured, the platform needs to know that a custom module has completed data fetching and rendering so that a loading UI state does not appear on the PDF. TheDeferPdfCapture component in the @hubspot/quote-dev-sdk will allow custom coded modules to signal when they’ve completed loading, so that the PDF capture happens after data fetching and rendering is complete.
The
DeferPdfCapture component requires @hubspot/quote-dev-sdk v0.4.0 or later.DeferPdfCapture component in your custom module:
- Import the
DeferPdfCapturecomponent as an island in a module. - Ensure the component is rendered during the initial server-side render. Do not use
DeferPdfCaptureinclientOnlyislands.
The code block below demonstrates example usage of the component:
- All
DeferPdfCaptureinstances on the quote must be set to ready within 25 seconds of the page loading. If any instance isn’t ready by then, the PDF capture fails. To prevent PDF capture when an error occurs, the following pattern is recommended:
- Developer console logs are available for viewing in client browsers, so developers can inspect and debug issues with
DeferPdfCaptureresolution
Quote buyer details hook
If you want to provide information about the buyer company and the options in the default header or parties modules, you can use theuseQuoteBuyerDetails hook from the @hubspot/quote-dev-sdk. This hook allows you to build your own buyer detail capture form and submit the data to be written back to the CRM.
The
useQuoteBuyerDetails hook requires @hubspot/quote-dev-sdk v0.4.0 or later.- From the header module, enable editing of Purchase Order Number.
- From the parties module, enable editing of Sold To, Bill To, and Tax ID.
quoteTemplateContext to determine if your buyer details capture form should render. These properties are not yet available to be written to via API.
quoteTemplateContext.quote.hs_bill_to_details_editabilitycontrolsbillingInfo.quoteTemplateContext.quote.hs_purchase_order_editabilitycontrolspurchaseOrderNumber.quoteTemplateContext.quote.hs_buyer_tax_id_editabilitycontrolsbuyerTaxIds.quoteTemplateContext.quote.hs_sold_to_details_editabilitycontrolssoldToCompany.
useQuoteBuyerDetails hook is used to read the current state of data, and submit new data via the actions.submit function:
data.values is detailed in the tabs below:
- BuyerBillingCompany
- BuyerBillingInfo
- BuyerSoldToCompany
- BuyerTaxId
Submission processing
A single submit call can update several sections: billing info, purchase order number, tax IDs and sold-to company. HubSpot processes them one at a time, in the following order:- Billing info
- Purchase order number
- Tax IDs
- Sold-to company
reportPdfStale from useQuotePdf. That is automatically handled, and the PDF will be automatically regenerated for the buyer after they submit data.
If the billing contact email matches an existing contact in the CRM, that contact becomes the quote’s billing contact, and its first and last name are updated from the submission.
- Five requests can be made per hour per quote. A request that fails validation and does not make an update counts toward this limit.
- Accepted, partially signed, and voided quotes cannot accept updates (the
canSubmitproperty will be set tofalse). - Billing Company must exist before providing Tax IDs. Billing Company and Tax IDs can be written in the same initial request.
- The name of the Billing Company or Sold To Company cannot be changed if the seller created the company. (
createdByBuyerwould befalse) - The
billingContactEmailcan be changed three times during the lifetime of the quote. If a buyer initially provides this information, that counts toward the limit of three.
- Validate fields in the browser with
getBuyerDetailsRules()before calling submit:- The
purchaseOrderNumberproperty has a maximum of 50 characters, and only allowed characters are letters, digits, spaces, and_,/,;,:,(,),.,&,?,!,-, and\. - For the
buyerTaxIdsproperty, a limit of 3 tax IDs is enforced. Each tax ID has a maximum of 30 characters (not including tax type code), and the only allowed characters are letters, digits, spaces, and_,/,:,(,),.,&,?,!,-, and\. - Keep in mind some checks only run on the server, such as email deliverability, the ability to edit certain fields, and whether a company name can be changed, so a submission can still fail despite full validation in your code.
- The
- Only include sections where the associated property is editable. A section that isn’t editable fails and stops the sections after it.
- To keep sections independent, submit them in separate calls. This uses more of the hourly limit.
Error handling
When thesubmit action receives an error from the API, it will throw an error with one of the following code values:
Each submission counts toward the rate limit of five per hour per quote, including submits that fail validation. The limit is shared by everything that edits the quote’s buyer details, including HubSpot’s header and parties modules.
The code block below provides a starting point for handling different errors in your code:
Upload the project
To upload the example project to your HubSpot account, run the following CLI command:Add the module to a quote
To see your module in the quote editor:- In your HubSpot account, navigate to Commerce > Quotes.
- In the upper right, click Create quote, then select Create quote.
- In the right panel, select a deal and quote template to use for the quote. Then, click Create quote.
- In the left sidebar of the quote editor, click the plus icon.
- Drag and drop the Example Module into the quote.


Published quote behavior
Quotes are rendered once at the time of publish. Keep the following in mind when updating or removing custom modules:- If you deploy a new version of a custom module, the changes will apply to future quotes and any unpublished drafts, but not to quotes that have already been published.
- If you delete or remove a custom module from the project, it will affect unpublished quotes and templates that use it. Published quotes will not be affected. Learn more about deleting and restoring modules.
Delete and restore modules
Impact of deleting a module
When you deploy a new build with a module removed from the project:- The module is no longer available when creating new quote templates or quotes.
- Existing published quotes are unaffected until they are recalled.
- Templates or draft quotes that use the deleted module will automatically have the module removed. When a user edits one of these templates or draft quotes, an alert will be shown informing them about the deletion.
Restore a deleted module
Once a module is deleted through a deploy, it cannot be restored by adding the module file back to your local project and re-uploading. Instead, deploy an older build that still contains the module through the projects UI in HubSpot. This makes the module available again so it can be added to new quote templates and quotes. However, templates or draft quotes that were already saved with the module removed will not have the module added back automatically — the module must be re-added to those templates or drafts manually.- In your HubSpot account, navigate to Development. Then, click the name of your project.
- Click the Builds & Deploys tab.
- Find the build that contains the module you want to restore, then click Deploy.
- Before your next CLI upload, ensure your local project includes the original module file and any changes from newer builds so they aren’t lost on the next deploy.