> ## Documentation Index
> Fetch the complete documentation index at: https://formcarry.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Protect Your Forms with Google reCAPTCHA v2 and v3

> Add Google reCAPTCHA v2 checkbox or v3 to your formcarry forms to block spam bots and protect submissions from automated abuse with server-side validation.

Google reCAPTCHA adds an extra layer of bot protection to your forms. After you paste your secret key into your form settings, formcarry validates every submission against Google's reCAPTCHA API before accepting it.

<Note>
  formcarry supports **reCAPTCHA v2 Checkbox** and **reCAPTCHA v3**. reCAPTCHA v2 Invisible is not supported.
</Note>

## Get Your reCAPTCHA Keys

<Steps>
  <Step title="Open the Google reCAPTCHA Admin Console">
    Go to the [Google reCAPTCHA Admin Console](https://www.google.com/recaptcha/admin) and sign in with your Google account.
  </Step>

  <Step title="Register a new site">
    Click **+** to register a new site. Fill in your site label, select your reCAPTCHA type (v2 Checkbox or v3), and add your domains. Include `localhost` if you need to test locally.
  </Step>

  <Step title="Copy your keys">
    After clicking **Submit**, Google generates two keys:

    * **Site Key** — used in your HTML markup
    * **Secret Key** — pasted into formcarry to enable server-side validation
  </Step>
</Steps>

## Using reCAPTCHA v2 (Checkbox)

<Steps>
  <Step title="Add the reCAPTCHA script to your page">
    Paste the following script tag inside your `<head>`:

    ```html theme={null}
    <script src="https://www.google.com/recaptcha/api.js"></script>
    ```
  </Step>

  <Step title="Add the reCAPTCHA widget to your form">
    Place the `g-recaptcha` div inside your form, replacing `YOUR_SITE_KEY` with the Site Key from the Admin Console:

    ```html theme={null}
    <form action="https://formcarry.com/s/XXXX" method="POST" enctype="multipart/form-data">
      <!-- your other fields -->
      <div class="g-recaptcha" data-sitekey="YOUR_SITE_KEY"></div>
      <button type="submit">Submit</button>
    </form>
    ```
  </Step>

  <Step title="Copy your Secret Key">
    Return to the [Google reCAPTCHA Admin Console](https://www.google.com/recaptcha/admin) and copy the **Secret Key** for your site.
  </Step>

  <Step title="Enable reCAPTCHA in formcarry">
    In the formcarry dashboard, open your form's **Settings**, enable the **Google reCAPTCHA** toggle, paste your Secret Key into the field, and click **Save**.
  </Step>
</Steps>

## Using reCAPTCHA v3

<Steps>
  <Step title="Add the reCAPTCHA v3 script">
    Add the v3 script to your `<head>`, passing your Site Key as the `render` parameter:

    ```html theme={null}
    <script src="https://www.google.com/recaptcha/api.js?render=YOUR_SITE_KEY"></script>
    ```
  </Step>

  <Step title="Add a hidden input to your form">
    Add a hidden input that will hold the reCAPTCHA token formcarry reads on submission:

    ```html theme={null}
    <input type="hidden" id="captchaResponse" name="g-recaptcha-response" />
    ```
  </Step>

  <Step title="Execute reCAPTCHA and populate the hidden input">
    Use JavaScript to request a token from Google and write it into the hidden input before the form is submitted:

    ```javascript theme={null}
    grecaptcha.ready(function() {
      grecaptcha.execute('YOUR_SITE_KEY', { action: 'homepage' })
        .then(function(token) {
          document.getElementById('captchaResponse').value = token;
        });
    });
    ```
  </Step>

  <Step title="Enable reCAPTCHA in formcarry">
    Copy your **Secret Key** from the [Google reCAPTCHA Admin Console](https://www.google.com/recaptcha/admin), open your form's **Settings** in formcarry, enable the **Google reCAPTCHA** toggle, paste the Secret Key, and click **Save**.
  </Step>
</Steps>

<Warning>
  Add `localhost` to your reCAPTCHA domain list when testing locally. Without it, the widget will throw a domain mismatch error and your submissions won't pass validation.
</Warning>


## Related topics

- [React](/docs/frameworks/react.md)
- [JavaScript](/docs/frameworks/javascript.md)
- [Next.js](/docs/frameworks/nextjs.md)
- [jQuery](/docs/frameworks/jquery.md)
- [formcarry.js](/docs/frameworks/formcarry-js.md)
