Skip to main content
Deflect’s JavaScript SDK allows you to integrate bot protection seamlessly into any frontend application including React, Vue, Next.js, or plain JavaScript.

Installation

Add the script tag directly to your HTML file:
Use @latest to always get the latest version, or specify a version with @deflectbot/[email protected].

NPM/Yarn

If you prefer using a package manager:

npm

yarn

Then import it in your JavaScript:

Quick Start

1. Configure the SDK

Configure Deflect with your Action ID (get this from your dashboard):
Call this once early in your app’s lifecycle, before making any protected API calls.

2. Get a token for protected requests

When you need to make a request to a protected endpoint (login, register, payment, etc.):

3. Form Helper (Optional)

If you’re using HTML forms, you can use the helper function:
The injectToken() function will automatically fetch a token and inject it as a hidden input named deflect_token into your form.

Complete Example

Here’s a full working example:

Next Steps

After implementing the client-side SDK, you’ll need to verify the tokens on your backend using the Verdict API.