Forms with Next Js or React

Has anyone succeeded getting the (non iframe) sign-up forms work with Next js or React?

I am trying to build my own customised form, but struggling due to errors coming from main.js lib related to removeClass (which I think it’s a jQuery dependency)?

Any sample code for a simple form using own styles in these frameworks would be appreciated

Hi @capricorn , thanks for your message. What is the error displayed?

I’ve tried in so many different ways, no luck.

Could you share a simple hello world example in React or NextJs?

Hi @ahudavert , I’ve finally managed to get it working in React, but only with Google reCaptcha v2. I Couldn’t get Cloudflare Turnstile to work at all.

I’d stil like to ask for a sample code that decouple’s your UI from the form submission endpoint. I want to build my own custom form, but now I’m forced to use your divs and classes and main.js. The form breaks if I remove a single class that the main.js expects. Ideally we have a decoupled way, so I could also tap on supported npm packages for captcha/turnstile.

Anyway, for anyone that comes across this issue, here’s my BrevoForm.jsx component structure on how to load the captcha and Brevo’s main.js lib in a way that they properly reloads if you navigate away and back to the page (without that, due to the way React is caching the pages, those libs would not run if you navigate away and back to the page where the component is mounted).

const BrevoForm = ({ formURL }) => {
  const captchaScriptId = 'recaptcha-script'
  const mainScriptId = 'main-script'

  const loadScript = (scriptId, src) => {
    let script = document.getElementById(scriptId)
    if (!script) {
      script = document.createElement('script')
      script.src = src
      script.async = true
      script.defer = true = scriptId
    } else {
      // Update the script src to force reload if it's already present
      script.src = src

  const unloadScript = (scriptId) => {
    const script = document.getElementById(scriptId)
    if (script) {

  const loadRecaptchaScript = () => {
    const src = ``
    loadScript(captchaScriptId, src)

  const loadMainScript = () => {
    const src = ``
    loadScript(mainScriptId, src)

  useEffect(() => {

    return () => {
  }, [])

return (

      {/* ... rest of your JSX structure */}

        {/* ... rest of your form structure */}

      {/* ... rest of your JSX structure */}
export default BrevoForm

1 Like

Thanks a lot for all these details @capricorn .

It’s great if it finally works for you, and I guess this example will help the ones among us who will try to build forms with nextJS or React :+1: