TrustComponent
React
TrustCaptcha · Bot protection

React CAPTCHA Integration

TrustCaptcha's React CAPTCHA integration adds bot protection to your forms without image puzzles. It keeps spam out of sign-ups, contact forms and payments, and real visitors have nothing to solve. EU-hosted and GDPR-compliant.

Quickstart

How the integration works

1. Create a CAPTCHA

Create a user account or log in with an existing one. Then create a new CAPTCHA or pick an existing one. If you want to try TrustCaptcha first, every plan comes with a 14-day free trial.

The CAPTCHA overview page shows your site key and license key, and you create your API key there. Add your website’s domains to the authorized domains in the CAPTCHA security rules so they can use your CAPTCHA.

Start of the CAPTCHA creation form.
CAPTCHA security rules of a demo CAPTCHA.

2. Integrate the CAPTCHA widget into your frontend

The following steps show roughly how to add the TrustCaptcha widget to a React frontend. For the full instructions, read the CAPTCHA integration guide for React in our documentation.

Read the documentation

First, install our TrustCaptcha React package:

Install
bash
npm i @trustcomponent/trustcaptcha-react

Then add the CAPTCHA widget, the trustcaptcha-component HTML tag, to any HTML form:

app.js
javascript
import {TrustcaptchaComponent} from "@trustcomponent/trustcaptcha-react";

function App() {

  function handleSuccess(verificationToken) { /* handle success */ }

  function handleError(error) { /* handle error */ }

  return (
    <div>
      <form>
        <!-- your input fields -->
        <TrustcaptchaComponent
          sitekey="<your_site_key>"
          onCaptchaSolved={event => handleSuccess(event.detail)}
          onCaptchaFailed={event => handleError(event.detail)}
        ></TrustcaptchaComponent>
        <!-- further input fields / submit button -->
      </form>
    </div>
  );
}

export default App;

The CAPTCHA widget will now be displayed on your React website:

CAPTCHA start

Need detailed information about the React CAPTCHA integration?
Our React CAPTCHA integration guide has the detailed instructions, and our CAPTCHA samples repository on GitHub has a complete integration example.

Other frontend technology instead of React?
If you build with something other than React, or run several websites and apps, pick a different framework or platform here. If we have no pre-built integration for your frontend technology yet, your developers can integrate the CAPTCHA themselves using our documentation or ask our support team for a pre-built integration.

Angular
Contact Form 7
Craft CMS
JavaScript
Joomla
JTL-Shop
Keycloak
Magento 2
React
Shopware 6
Svelte
TYPO3
Vue
Webflow
WordPress

3. Validate the CAPTCHA result in your backend

When the CAPTCHA is complete, send the verification token to your backend. There, fetch the verification result from our servers and check it. How you proceed depends on the bot risk. You can find details on backend integration and result validation in our documentation.

Pre-built backend integrations
Our pre-built integrations add the CAPTCHA validation to your backend service. If there is none for your backend technology yet, your developers can integrate the validation themselves using our documentation or ask our support team for a pre-built integration.

.NET
Go
Groovy
Java
Kotlin
Node.js
PHP
Python
Ruby
Rust
Scala

4. Test your integration

TrustCaptcha is now active. Send a test request and check that it goes through.

CAPTCHA done

FAQs

What do I need to add a React CAPTCHA to my app?
You need a TrustCaptcha account, a CAPTCHA you created in the dashboard, and your credentials (site-key, API key, and optional license-key). In React, you install the React package and place the TrustCaptcha component inside the form you want to protect.
Does the TrustCaptcha widget have to be inside a <form>?
Yes. The TrustCaptcha component must be placed inside a form element. If your page does not use a traditional form, wrap the relevant inputs and the TrustCaptcha component in a minimal <form> anyway.
How do I get the verification token in React?
You have two options: (1) read it from the hidden input field (default name: "tc-verification-token"), or (2) capture it via the component event (for example, using the React handler "onCaptchaSolved"). Use whichever fits your form and API flow best.
Do I still need to validate the CAPTCHA on my backend?
Yes, always. The React widget only produces a verification token. Your backend must send that token to TrustCaptcha (using your API key) and evaluate the result before you accept a signup, login, checkout, or contact request.
Can I use multiple TrustCaptcha widgets on one page?
Yes. Multiple forms on the same page are fine. If you place more than one widget in the same form, give each widget its own token field name (for example via "tokenFieldName") or rely on the events so you can keep tokens separate.
Where should I place TrustCaptcha in a multi-step (wizard) form?
Place it close to the final submit action. By default, the verification token is single-use and valid for 15 minutes. On the Enterprise plan you can extend the validity and allow a limited number of retrievals. Solving the CAPTCHA too early in a long flow can cause avoidable re-tries.
Does TrustCaptcha work with React SSR/SSG frameworks (for example, Next.js)?
Yes. TrustCaptcha supports common React setups, including SSR/SSG. In practice, many teams render the widget on the client side (in the browser) so the verification can run normally, and then validate the token on the server.
Losing leads to CAPTCHAs?

TrustCaptcha blocks spam and bots, not customers. No puzzles, GDPR-compliant, EU-hosted.

CAPTCHA start
CAPTCHA done
No puzzles for visitors
The check runs in the background while visitors type, so more people finish your forms instead of giving up.
GDPR-compliant
Hosted in the EU, no cookies, encrypted transmission and automatic data deletion. Every customer gets a Data Processing Agreement.
Multi-layer security
Adaptive proof-of-work and risk scoring stop abuse early, even when attack traffic spikes.
Full control
Set the sensitivity, keep allow and block lists and use geoblocking. You decide how strict the check is.

Protect your React application with TrustCaptcha in just a few steps!

  • EU-hosted & GDPR-compliant
  • No puzzles
  • Try free for 14 days