TrustComponent
Svelte
TrustCaptcha · Bot protection

Svelte CAPTCHA Integration

Add a Svelte CAPTCHA to your Svelte or SvelteKit forms in minutes and block bots and spam on sign-ups, logins and checkouts. A lightweight wrapper component takes your site key. No puzzles, EU-hosted and GDPR-compliant, with a bot score and security rules.

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 Svelte frontend. For the full instructions, read the CAPTCHA integration guide for Svelte in our documentation.

Read the documentation

First, install the Svelte wrapper package:

Install
bash
npm i trustcaptcha-svelte

Then add the CAPTCHA widget, the TrustCaptcha element, to any HTML form:

App.svelte
svelte
<script lang="ts">
  import { TrustCaptcha } from "trustcaptcha-svelte";

  function solved(event: CustomEvent<string>) {
    const VerificationToken = event.detail;
    // send VerificationToken to your backend
  }

  function failed(event: CustomEvent) {
    const error = event.detail;
    // handle error
  }
</script>

<form>
  <!-- your input fields -->
  <TrustCaptcha
    sitekey="<your_SiteKey>"
    oncaptchaSolved={solved}
    oncaptchaFailed={failed}
  />
  <!-- further input fields / submit button -->
</form>

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

CAPTCHA start

Note: The Svelte wrapper is a community integration maintained on GitHub by Frederic Lehmann: FrediLehmann/trustcaptcha-svelte

Need detailed information about the Svelte CAPTCHA integration?
Our Svelte CAPTCHA integration guide has the detailed instructions.

Other frontend technology instead of Svelte?
If you build with something other than Svelte, 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 get started with a Svelte CAPTCHA?
You need a site-key in your Svelte form and a backend endpoint that sends the verification token to TrustCaptcha using your API key to fetch the verification result.
Does it work with SvelteKit and SSR?
Yes. Render the widget inside a form and validate the verification token on the server side. In SvelteKit, validate in your server code (form actions or endpoints).
How do I receive the verification token?
After solving, the widget writes the verification token into a hidden field (tokenFieldName) and also emits it via the oncaptchaSolved event, so you can send it to your backend.
How should I use the bot score?
The verification result includes verificationPassed and bot score. A common start is to accept below 0.5 and reject above 0.5, then adjust based on your traffic and risk tolerance.
Can I add multiple widgets or forms on one page?
Yes. You can use multiple widgets and forms. If you rely on hidden fields, set a unique tokenFieldName per form; with events, just handle each verification token separately.
How long is a verification token valid?
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. Place the widget near the submit button.
Can I customize the widget in Svelte?
Yes. Set theme, language and autostart on the component. Custom design needs a license key and is included from the Team plan. A fully invisible widget and hiding our branding are the paid Captcha Branding add-on.
Do I have to use the Svelte wrapper?
No. You can also integrate TrustCaptcha directly as a JavaScript web component in any Svelte app. The wrapper just makes installation and event handling more convenient.
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 Svelte application with TrustCaptcha in just a few steps!

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