next-hubspot
v2.0.1
Published
Hubspot forms in Next.js with no headache
Maintainers
Readme
⭐ Hubspot Forms for Next.js
Embed HubSpot forms into your Next.js application using hooks.
🌳 Tiny and Tree-Shakable
🦄 Written in TypeScript
👾 Works with multiple forms
😎 Uses next/script component
Install
npm install next-hubspotor
pnpm add next-hubspotor
yarn add next-hubspotPure ESM package
This package is now pure ESM. It cannot be require()'d from CommonJS.
Getting Started
Wrap your application with HubspotProvider. This will add Hubspot script to your document.
All props are passed directly to the Script tag, so you can use all props from the next/script documentation.
import { HubspotProvider } from 'next-hubspot';
const MyApp = ({ Component, pageProps }) => (
<HubspotProvider>
<Component {...pageProps} />
</HubspotProvider>
)
Usage
import { useHubspotForm } from 'next-hubspot';
const HubspotForm = () => {
const { isFormCreated, isError, error } = useHubspotForm({
portalId: 'XXXXXXX',
formId: 'XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX',
target: '#hubspot-form-wrapper'
});
return (
<div id="hubspot-form-wrapper" />
)
}All props are based on the HubSpot docs.
Related Official Hubspot Documentation:
- hubspot-form-if-im-using-an-external-site
- forms/advanced_form_options
- building-blocks/forms
- buildung-blocks/forms#using-embed-code
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!
