npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ez-digital/react-hubspot-hook-form

v1.4.3

Published

A React library integrating HubSpot forms with React Hook Form for easy form validation and submission.

Downloads

195

Readme

HubSpot Form Component

License Issues RELEASES TypeScript LINKEDIN

This package provides a React component to integrate and customize HubSpot forms seamlessly. It leverages react-hook-form for form handling and validation, allowing you to easily include HubSpot forms in your React applications.

Features

  • Fetches and displays HubSpot forms dynamically based on form ID.
  • Customizable form and field styles.
  • Client-side validation with react-hook-form.
  • Handles form submission with HubSpot API integration.
  • Displays success and error messages.

Installation

To install the package, use npm or yarn:

npm install react-hubspot-hook-form

or

yarn add react-hubspot-hook-form

Pure ESM package

This package is pure ESM. It cannot be require()'d from CommonJS.

Usage

It's crucial to keep your PORTAL_ID and HUBSPOT_API_TOKEN secure to prevent unauthorized form submissions and other actions. To achieve this, set up your own server to store these environment variables and handle form requests. Remember, HubSpot mandates that form data requests be submitted from a server, rejecting any client-side requests.

React Example Next.js Example

How to Obtain a HubSpot API Token

To obtain your HubSpot API token, please visit this link.

Props

The HubSpotForm component accepts the following props:

Here's the updated table and corresponding documentation:

Table

| Prop | Type | Default | Description | | ------------------------- | --------------------- | --------------------------------------------- | ------------------------------------------------------------ | | fieldGroups | FieldGroup[] | Required | An array of field groups to be displayed in the form. | | submitButtonText | string | Required | The text to display on the submit button. | | onSubmit | SubmitHandler<T> | Required | The form submit handler function. | | isLoading | boolean | false | Indicates if the form is currently loading data. | | isSubmitting | boolean | false | Indicates if the form is currently being submitted. | | isSubmitted | boolean | false | Indicates if the form has been successfully submitted. | | loader | ReactNode | Custom loader | Custom loader component to display while fetching form data. | | skeletonHeight | number \| string | 400 | Height of the skeleton loader. | | successMessage | string | "The form has been submitted successfully." | Message displayed upon successful form submission. | | errorMessage | string | undefined | Message displayed upon form submission error. | | formStyles | React.CSSProperties | {} | Custom styles for the form container. | | formClassName | string | "" | Custom class name for the form container. | | fieldGroupStyles | React.CSSProperties | {} | Custom styles for the field groups. | | fieldGroupClassName | string | "" | Custom class name for the field groups. | | fieldControlStyles | React.CSSProperties | {} | Custom styles for the field controls. | | fieldControlClassName | string | "" | Custom class name for the field controls. | | labelStyles | React.CSSProperties | {} | Custom styles for the labels. | | labelClassName | string | "" | Custom class name for the labels. | | fieldStyles | React.CSSProperties | {} | Custom styles for the input fields. | | fieldClassName | string | "" | Custom class name for the input fields. | | successMessageStyles | React.CSSProperties | {} | Custom styles for the success message. | | successMessageClassName | string | "" | Custom class name for the success message. | | errorMessageStyles | React.CSSProperties | {} | Custom styles for the error message. | | errorMessageClassName | string | "" | Custom class name for the error message. | | buttonStyles | React.CSSProperties | {} | Custom styles for the submit button. | | buttonClassName | string | "" | Custom class name for the submit button. |

Customization

You can customize the appearance and behavior of the form by passing custom styles and class names for various parts of the form. Additionally, you can provide custom loader components, success messages, and error messages to match the look and feel of your application. Use the provided styles from @ez-digital/react-hubspot-hook-form/style or style the form by yourself.

Example

Here is a more detailed example demonstrating customization:

import React from "react";
import ReactDOM from "react-dom";

import HubSpotForm from "@ez-digital/react-hubspot-hook-form";
import "@ez-digital/react-hubspot-hook-form/style";

const customStyles = {
  formStyles: { padding: "20px", backgroundColor: "#f9f9f9" },
  fieldGroupStyles: { marginBottom: "15px" },
  labelStyles: { fontWeight: "bold" },
  fieldStyles: { padding: "10px", borderRadius: "4px" },
  buttonStyles: { backgroundColor: "#007bff", color: "#fff" },
};

const App = () => {
  return (
    <HubSpotForm
      successMessage="Thank you for your submission!"
      errorMessage="Please correct the errors and try again."
      formStyles={customStyles.formStyles}
      fieldGroupStyles={customStyles.fieldGroupStyles}
      labelStyles={customStyles.labelStyles}
      fieldStyles={customStyles.fieldStyles}
      buttonStyles={customStyles.buttonStyles}
    />
  );
};

ReactDOM.render(<App />, document.getElementById("root"));

TypeScript

The module is written in TypeScript and type definitions are included.

Contributing

Contributions, issues and feature requests are welcome!

Show your support

Give a ⭐️ if you like this project!

License

This package is licensed under the MIT License. See the LICENSE file for more information.