JavaScript CAPTCHA Integration
Add a JavaScript CAPTCHA to any website in minutes with a simple form widget. It protects sign-ups, password resets, lead forms and checkouts from automated abuse, without puzzles. EU-hosted, GDPR-compliant and built with accessibility in mind.
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.


2. Integrate the CAPTCHA widget into your frontend
The following steps show roughly how to add the TrustCaptcha widget to a JavaScript frontend. For the full instructions, read the CAPTCHA integration guide for JavaScript in our documentation.
Read the documentation
First, install our TrustCaptcha JavaScript package:
ECMAScript Modules (esm)
<script type="module" src="https://cdn.trustcomponent.com/trustcaptcha/3.0.x/trustcaptcha.esm.min.js"></script>
CommenJS (cjs)
<script src="https://cdn.trustcomponent.com/trustcaptcha/3.0.x/trustcaptcha.cjs.min.js"></script>
Universal Module Definition (umd)
<script src="https://cdn.trustcomponent.com/trustcaptcha/3.0.x/trustcaptcha.umd.min.js"></script>Then add the CAPTCHA widget, the trustcaptcha-component HTML tag, to any HTML form:
<form>
<!-- your input fields -->
<trustcaptcha-component
sitekey="<your_site_key>"
></trustcaptcha-component>
<!-- further input fields / submit button -->
</form>
<script>
const trustcaptchaComponent = document.getElementsByTagName('trustcaptcha-component')[0];
trustcaptchaComponent.addEventListener('captchaSolved', (event) => {
console.log('Verification token:', event.detail); <!-- handle success -->
});
trustcaptchaComponent.addEventListener('captchaFailed', (event) => {
console.error(event.detail); <!-- handle error -->
});
</script>The CAPTCHA widget will now be displayed on your JavaScript website:

Need detailed information about the JavaScript CAPTCHA integration?
Our JavaScript CAPTCHA integration guide has the detailed instructions, and our CAPTCHA samples repository on GitHub has a complete integration example.
Other frontend technology instead of JavaScript?
If you build with something other than JavaScript, 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.
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.
4. Test your integration
TrustCaptcha is now active. Send a test request and check that it goes through.

FAQs
What do I need for a JavaScript CAPTCHA on a plain website?
Does it work only with JavaScript, or also with other frameworks and CMS platforms?
Why does the CAPTCHA have to be placed inside a <form>?
How do I get the verification token and send it to my server?
Do I still need server-side validation, or is the frontend widget enough?
Can we self-host the JavaScript file instead of loading it from your CDN?
How do we set up authorized websites (domains) for production and development?
Can I use multiple CAPTCHAs on the same page?
TrustCaptcha blocks spam and bots, not customers. No puzzles, GDPR-compliant, EU-hosted.


Protect your JavaScript application with TrustCaptcha in just a few steps!
- EU-hosted & GDPR-compliant
- No puzzles
- Try free for 14 days