React
TrustCaptcha – Bot protection

React CAPTCHA Integration

TrustCaptcha’s React CAPTCHA integration adds instant bot protection to your forms—no image puzzles, no friction. Keep sign-ups, contact forms and payments spam-free and conversion-friendly. EU-hosted and GDPR-ready.

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 select an existing one. If you’re unsure whether TrustCaptcha is right for you, try our CAPTCHA service risk-free for 14 days at no cost.

On the CAPTCHA overview page, you will find all the important information, such as the site key, secret key and licence key. Allow your websites to access your CAPTCHA by simply adding them to the access authorised domain list in the CAPTCHA security rules.

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

2. Integrate the CAPTCHA widget into your frontend

The following steps give you a rough idea of how to integrate the TrustCaptcha CAPTCHA widget into an React frontend. For precise, detailed instructions, please 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

Now insert the CAPTCHA widget, the so-called trustcaptcha-component HTML tag, into any HTML form:

app.js
javascript
import {TrustcaptchaComponent} from "@trustcaptcha/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 done

Need detailed information about the React CAPTCHA integration?
For detailed instructions on integrating TrustCaptcha, please refer to our React CAPTCHA integration guide. A complete integration example for the React CAPTCHA can be found in our CAPTCHA Samples Repository on Github.

Other frontend technology instead of React?
If you do not want to use React or have several websites or applications, you can select a different framework or platform here. If there is no pre-built integration from us for your preferred frontend technology, your software developers can integrate the CAPTCHA themselves using our documentation or ask our support-team for a pre-built integration solution.

Android
Angular
Craft CMS
Flutter
iOS
JavaScript
Joomla
Keycloak
Magento 2
React
React Native
TYPO3
Vue
Webflow
WordPress

3. Validate the CAPTCHA result in your backend

Once the CAPTCHA is complete, take the verification token and send it to your backend. In your backend, retrieve the CAPTCHA verification result from our servers and validate the result. Depending on how high the bot risk is, you decide how to proceed. You can find detailed information on backend integration and result validation in our documentation.

Prebuild backend integrations
You can use one of our pre-built integrations to integrate the CAPTCHA validation process into your backend service. If there is no pre-built integration from us for your preferred backend technology, your software developers can integrate the CAPTCHA themselves using using our documentation or ask our support-team for a pre-built integration solution.

.Net
Go
Groovy
Java
Kotlin
Nodejs
PHP
Python
Ruby
Rust
Scala
Spring

4. Congratulations 🎉

You are now protected by TrustCaptcha - congratulations!

CAPTCHA done

FAQs

What do I need to integrate TrustCaptcha in a React app?
You need a TrustCaptcha account, a CAPTCHA you created in the dashboard, and your credentials (site-key, secret-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 secret-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. Verification results are time-limited and typically fetched only once, so 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-ready, EU-hosted.

CAPTCHA start
CAPTCHA done
Puzzle-free UX
Runs in the background while visitors type — so more people finish your forms and fewer drop off.
GDPR-ready
EU-hosted and privacy-first: no cookies, encrypted transmission, automatic cleanup — with ready-to-use legal resources.
Multi-layer Security
Adaptive protection plus intelligent risk scoring stops abuse early — even when attack traffic spikes.
Full Control
Fine-tune sensitivity, set allow/block lists, and use geoblocking — you decide how strict verification should be.

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

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