---
title: "Bot protection"
description: "Set up the bot check that guards sign-in and sign-up: Vercel BotID on Vercel, or a Cloudflare Turnstile challenge on any other host, with its keys."
canonical_url: "https://nuxt-backend.dev/docs/services/bot-protection"
---
# Bot protection

> Set up the bot check that guards sign-in and sign-up: Vercel BotID on Vercel, or a Cloudflare Turnstile challenge on any other host, with its keys.

Version: nuxt-backend 0.6.x · Tab: Services · Kind: how-to · Status: stable

Every page: [llms.txt](https://nuxt-backend.dev/llms.txt) · Skill for coding agents: [nuxt-backend](https://nuxt-backend.dev/.well-known/skills/nuxt-backend/SKILL.md)

Commands use npm; use your project's package manager.

Bot protection checks that a person, not a script, asks for a sign-in code or creates an account. On Vercel it runs as BotID and needs no account. On any other host it runs as a Cloudflare Turnstile challenge.

<table>
<thead>
  <tr>
    <th>
      You need
    </th>
    
    <th>
      Time
    </th>
    
    <th>
      Cost to start
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      On Vercel: one secret. Elsewhere: a free Cloudflare account
    </td>
    
    <td>
      5 minutes
    </td>
    
    <td>
      Free
    </td>
  </tr>
</tbody>
</table>

## What it powers

<table>
<thead>
  <tr>
    <th>
      Capability
    </th>
    
    <th>
      What it gives
    </th>
    
    <th>
      Build pages
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        protection
      </code>
    </td>
    
    <td>
      A check before the auth route that sends a sign-in code, which sign-up starts with too
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/build/auth/sign-in/bots">
        Stop bots
      </a>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        protection
      </code>
    </td>
    
    <td>
      <code>
        useHumanCheck
      </code>
      
       and <code>
        verifyHuman
      </code>
      
      , for a public form or vote of your own
    </td>
    
    <td>
      <a href="https://nuxt-backend.dev/docs/build/auth/sign-in/bots#protect-your-own-calls">
        Protect your own calls
      </a>
    </td>
  </tr>
</tbody>
</table>

The rate limits bound how fast one address or client can go; the bot check decides whether a person asks at all ([Tune rate limits](https://nuxt-backend.dev/docs/ship/security/rate-limits)). A request that fails it is refused as `forbidden` with reason `bot_check`.

## Create the account

**On Vercel, BotID:**

<steps level="3">

### Nothing to sign up for

BotID's basic check is part of every Vercel plan. Install its package, an optional peer of nuxt-backend:

```bash
npm install botid
```

A build on Vercel with `botid` installed turns it on in the browser and on the Nuxt server, with no module of yours to add: the package wires BotID's client and the server's `checkBotId()` itself, and Vercel's own `botid/nuxt` module is not needed. A Vercel build without it says so in its log, and runs no bot check on the app's server. Deep Analysis, on Pro, is a setting under the project's **Firewall**, **Rules**.

### Generate the proof secret

Once BotID passes, the Nuxt server signs a short-lived proof the deployment checks, so a bot that calls the deployment's own URL is refused too. Both sides share one secret:

```bash
openssl rand -base64 32
```

</steps>

**Elsewhere, a Turnstile challenge:**

<steps level="3">

### Sign up at Cloudflare

At [dash.cloudflare.com/sign-up](https://dash.cloudflare.com/sign-up). Your site does not need to run through Cloudflare.

### Create a widget

**Turnstile**, **Add widget**. Name it, add your app's hostnames, and choose **Managed** or **Invisible**: the package shows it only when Cloudflare asks for a click. Copy the site key and the secret key ([Get started](https://developers.cloudflare.com/turnstile/get-started/)).

</steps>

**Who should own it.** Whoever owns the host owns the check: the Vercel team, or the Cloudflare account that holds the widget.

## Sandbox and test mode

The dev server's check answers human without asking, as BotID itself does in development, so sign-in never stalls on your machine. The deployment checks nothing until a secret is set.

<table>
<thead>
  <tr>
    <th>
      Where the app runs
    </th>
    
    <th>
      What checks for bots
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        npx nuxt-backend dev
      </code>
    </td>
    
    <td>
      Nothing: the check answers human. With <code>
        PROTECTION_PROOF_SECRET
      </code>
      
       in <code>
        .env.local
      </code>
      
      , the dev server signs proofs and the dev deployment checks them
    </td>
  </tr>
  
  <tr>
    <td>
      A build on Vercel
    </td>
    
    <td>
      BotID, then the proof
    </td>
  </tr>
  
  <tr>
    <td>
      A build elsewhere, with a site key
    </td>
    
    <td>
      The Turnstile challenge
    </td>
  </tr>
</tbody>
</table>

To see a challenge on your machine, use Cloudflare's test keys:

<table>
<thead>
  <tr>
    <th>
      Site key
    </th>
    
    <th>
      Secret key
    </th>
    
    <th>
      Result
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        1x00000000000000000000AA
      </code>
    </td>
    
    <td>
      <code>
        1x0000000000000000000000000000000AA
      </code>
    </td>
    
    <td>
      Always passes
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        2x00000000000000000000AB
      </code>
    </td>
    
    <td>
      <code>
        2x0000000000000000000000000000000AA
      </code>
    </td>
    
    <td>
      Always fails, so you see <code>
        bot_check
      </code>
    </td>
  </tr>
</tbody>
</table>

`doctor --prod` fails a production that runs on the test keys ([Testing](https://developers.cloudflare.com/turnstile/troubleshooting/testing/)).

## Keys and environment

<table>
<thead>
  <tr>
    <th>
      Variable
    </th>
    
    <th>
      Where to find it
    </th>
    
    <th>
      Dev
    </th>
    
    <th>
      Prod
    </th>
    
    <th>
      Secret
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        PROTECTION_PROOF_SECRET
      </code>
    </td>
    
    <td>
      Generate it. On Vercel only: the same value on the deployment and in the Vercel project
    </td>
    
    <td>
      Optional, in <code>
        .env.local
      </code>
    </td>
    
    <td>
      Production's own, never <code>
        .env.local
      </code>
      
      's
    </td>
    
    <td>
      Yes
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        NUXT_PUBLIC_BACKEND_CHALLENGE_SITE_KEY
      </code>
    </td>
    
    <td>
      The Turnstile widget's site key, in the app host's env
    </td>
    
    <td>
      A test key, optional
    </td>
    
    <td>
      The widget's key
    </td>
    
    <td>
      No: the page needs it
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        PROTECTION_CHALLENGE_SECRET_KEY
      </code>
    </td>
    
    <td>
      The Turnstile widget's secret key, on the deployment
    </td>
    
    <td>
      A test key, optional
    </td>
    
    <td>
      The widget's key
    </td>
    
    <td>
      Yes
    </td>
  </tr>
</tbody>
</table>

## Link it

### On Vercel

```bash
SECRET=$(openssl rand -base64 32)
printf %s "$SECRET" | npx convex env set --prod PROTECTION_PROOF_SECRET
printf %s "$SECRET" | vercel env add PROTECTION_PROOF_SECRET production
```

Then deploy. A proof is valid for one minute, for one route, one address and one deployment ([Why the deployment checks a proof](https://nuxt-backend.dev/docs/build/auth/sign-in/bots#why-the-deployment-checks-a-proof)).

### Elsewhere

Set the site key in the app host's env as `NUXT_PUBLIC_BACKEND_CHALLENGE_SITE_KEY`, then the secret key on the deployment:

```bash
npx convex env set --prod PROTECTION_CHALLENGE_SECRET_KEY
```

The module lets `https://challenges.cloudflare.com` into the security headers' `script-src` and `frame-src`. Off Vercel, set `PROTECTION_PROOF_SECRET` only beside the challenge keys: nothing signs a proof there.

## Check it

```bash
npx nuxt-backend doctor --only protection
```

<table>
<thead>
  <tr>
    <th>
      Finding
    </th>
    
    <th>
      What it checks
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/cli/diagnostics#bot-protection">
        <code>
          bot-protection
        </code>
      </a>
    </td>
    
    <td>
      What the deployment checks. Under <code>
        --prod
      </code>
      
      , it warns when nothing does
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/cli/diagnostics#protection-proof">
        <code>
          protection-proof
        </code>
      </a>
    </td>
    
    <td>
      A proof signed with your secret passes on the deployment. It sends no mail and spends no limit
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/cli/diagnostics#protection-challenge-keys">
        <code>
          protection-challenge-keys
        </code>
      </a>
    </td>
    
    <td>
      The app shows a widget whenever the deployment asks for an answer, and production runs on real keys
    </td>
  </tr>
  
  <tr>
    <td>
      <a href="https://nuxt-backend.dev/docs/reference/cli/diagnostics#deployment-protection-proof-secret">
        <code>
          deployment-protection-proof-secret
        </code>
      </a>
      
      , <a href="https://nuxt-backend.dev/docs/reference/cli/diagnostics#deployment-protection-challenge-secret-key">
        <code>
          deployment-protection-challenge-secret-key
        </code>
      </a>
    </td>
    
    <td>
      The deployment holds the secret it needs
    </td>
  </tr>
</tbody>
</table>

## Go to production

Give production its own secret or keys, as in [Link it](#link-it), deploy, then run:

```bash
vercel env pull
npx nuxt-backend doctor --prod
```

`doctor` reads the app's env only from your shell, so pull it first. To rotate the proof secret without downtime, set `new,old` on the deployment, move the app to the new value and redeploy, then set the new value alone ([Rotate secrets](https://nuxt-backend.dev/docs/ship/security/secrets)).

## Costs and limits

Checked on 2026-10-25:

- **BotID:** the basic check is free on every Vercel plan. Deep Analysis costs $1 per 1,000 checks, on Pro ([BotID](https://vercel.com/docs/botid)). It runs only on a Vercel deployment.
- **Turnstile:** free, with unlimited challenges, up to 20 widgets per account and 10 hostnames per widget ([Plans](https://developers.cloudflare.com/turnstile/plans/)). A token is valid for 300 seconds, once.
- **Proofs:** each is accepted for a minute, so a slow network never fails a person, and a stolen one is worth little.

## Data and compliance

- **BotID:** Vercel checks signals from the browser and the request, under its [DPA](https://vercel.com/legal/dpa).
- **Turnstile:** Cloudflare processes the visitor's IP address, TLS fingerprint and user agent to tell people from bots, and reads no form input. It acts as your processor under its [DPA](https://www.cloudflare.com/cloudflare-customer-dpa/) ([Turnstile privacy](https://www.cloudflare.com/turnstile-privacy-policy/)).
- **Cookies:** Turnstile sets a cookie only when you turn on its pre-clearance option.

Name the service you use in your privacy policy ([Privacy, GDPR and cookies](https://nuxt-backend.dev/docs/ship/compliance/privacy)). This is not legal advice.

## Related

- [Stop bots](https://nuxt-backend.dev/docs/build/auth/sign-in/bots): what the check protects, and how proofs work.
- [Tune rate limits](https://nuxt-backend.dev/docs/ship/security/rate-limits): the limits beside the bot check.
- [Vercel](https://nuxt-backend.dev/docs/services/vercel): the host BotID runs on.
- [Security model](https://nuxt-backend.dev/docs/ship/security): the whole threat model.
- [Service map](https://nuxt-backend.dev/docs/services): every service, and the order to set them up in.


## Sitemap

See the full [sitemap](https://nuxt-backend.dev/sitemap.md) for all pages.
