Bot Protection and Captchas for Forms
The day your form goes live, bots find it. Layered defenses stop nearly all of them without making real people solve puzzles. Here is the stack and the one check that cannot be skipped.

Key takeaways
- Stack cheap defenses first: a hidden honeypot field, a minimum time to submit, and a rate limit per address and per email.
- A captcha only works if your server verifies its token with the provider using the secret key. A widget alone stops nothing.
- Invisible or low-friction captchas such as Turnstile keep real users moving; puzzles are a last resort.
To protect a form from bots, combine a few layers: a hidden honeypot field bots fill in and people never see, a check that rejects submissions sent faster than a person could type, a rate limit per IP address and per email, and, for forms that attract real abuse, a captcha such as Cloudflare Turnstile, hCaptcha or Google reCAPTCHA. The captcha widget gives the browser a token; your server must send that token and your secret key to the provider's verify endpoint before accepting the form. Skipping that server check is the most common mistake, and it makes the captcha decorative.
What you will build
A protected form pipeline for the forms bots love: contact forms, waitlists, newsletter sign-ups, comment boxes, "request a quote", referral entries and contest submissions. Real people see a normal form (at most a small checkbox). Bots get quietly rejected or, better, receive a fake success so they do not adapt. You get a log of what was blocked and why.
What you are defending against
- Spam submissions: links and junk in contact forms and comments.
- Fake sign-ups: thousands of throwaway emails on a waitlist, which also hurts your email sender reputation when you mail them.
- Email bombing: bots entering a victim's address into your newsletter form so your app sends them hundreds of confirmation emails.
- Abuse of anything costly: forms that trigger SMS, AI calls or file processing, where each submission costs you money.
The last two are why protection is not optional for forms that send messages or call paid APIs. A single unprotected endpoint that triggers an SMS can produce a real bill overnight.
The free layers that stop most bots
- 01Honeypot. Add a field like "company_website" hidden with CSS (not type="hidden", which bots skip), with tabindex="-1" and autocomplete="off" so people and password managers leave it alone. If it arrives filled in, reject quietly.
- 02Time trap. Record when the form was rendered and reject submissions that arrive in under 3 seconds. Sign the timestamp on the server, or a bot can simply send an old one.
- 03Rate limits. Allow, say, 5 submissions per IP per 10 minutes and 3 per email per hour, stored in a small table or cache. What is rate limiting covers fixed and sliding windows.
- 04Content checks. Reject messages with more than a few links, or with the same text repeated, and validate emails properly.
- 05Double opt-in. For newsletters and waitlists, only count an address once its owner clicks the confirmation link. It stops fake lists and protects bombing victims, since they get one email, not hundreds.
Choosing a captcha
- Cloudflare Turnstile. Free, usually invisible or a single checkbox, no image puzzles. You need a Cloudflare account and create a widget for your domain to get a site key and a secret key.
- hCaptcha. Free tier available, privacy-focused, can show image challenges. Account, site key and secret key.
- Google reCAPTCHA v3. Invisible; returns a score from 0.0 (likely bot) to 1.0 (likely human) and you choose the threshold. A Google account, site key and secret key. Start around 0.5 and tune from your logs.
Whichever you choose, the pattern is identical. The site key is public and goes in the page. The secret key goes in your backend Secrets (for example TURNSTILE_SECRET_KEY) and is only used by server code. Add every domain the form runs on, including your startbase.app address and any custom domain, to the widget's allowed hostnames.
The data flow
- 01The page loads the provider's widget with your site key. When the user interacts, the widget produces a token and puts it in the form.
- 02The form posts its fields, the token, the honeypot and the signed render time to an edge function, never straight into a table.
- 03The function checks the honeypot, time and rate limit first (they are free), then posts the token, the secret key and optionally the visitor's IP to the provider's verify endpoint.
- 04The provider answers success or failure (plus a score for reCAPTCHA v3). Tokens are single-use and short-lived: Turnstile tokens expire after five minutes, so verify right away and never reuse one.
- 05Only on success does the function save the submission or send the email. Every rejection is logged with its reason.
A brief you can paste
Protect the waitlist and contact forms from bots. Add a hidden honeypot field (hidden with CSS, tabindex -1, autocomplete off) and a server-signed render timestamp; reject submissions under 3 seconds. Add Cloudflare Turnstile with our site key in the page and verify the token in an edge function using the TURNSTILE_SECRET_KEY secret before saving anything. Rate-limit to 5 submissions per IP per 10 minutes and 3 per email per hour. For the waitlist, send a confirmation email and only count confirmed addresses. When a submission is blocked, return the same success message a real user sees, and log the reason (honeypot, too fast, rate limit, captcha failed) in a blocked_submissions table I can view in the admin page.
Watching the logs and tuning
Protection is not set-and-forget. For the first two weeks after launch, look at the blocked_submissions log every few days. If the honeypot catches almost everything, you may not need a captcha on that form at all, and removing it helps conversions. If spam still gets through, check which layer it passed: a burst from one address means the rate limit is too loose; human-looking spam that arrives slowly is often a person paid to fill forms, which no captcha stops, and calls for content checks or moderation instead. With reCAPTCHA v3, chart the scores of accepted and blocked submissions before moving the threshold. Also watch the other direction: a real customer who emails "your form does not work" is worth more than a hundred blocked bots, so make the failure message say what to do next.
Pitfalls
- Verifying in the browser. Anything the browser decides, a bot can fake. The verify call must happen on the server with the secret key.
- Forms that write directly to the database. If your table accepts inserts from the public key, bots can skip your form and your captcha entirely. Route public submissions through a function, and lock the table with row level security.
- Forgetting a domain. A widget configured only for your custom domain fails on your preview or startbase.app address, and real users get stuck. List every host.
- Puzzle fatigue. Image challenges cost real conversions and are hard for people using screen readers. Prefer invisible modes and keep the cheap layers doing most of the work.
- Ignoring sign-up abuse. Your own forms are not the only target. If bots flood your app's account sign-up, Startbase Cloud's sign-in settings include an Invite only mode that blocks new sign-ups entirely while you investigate.
Frequently asked questions
What is a honeypot field?
A form field hidden from people with CSS. Real users never fill it in, but many bots fill in every field they find, so a filled honeypot marks the submission as a bot.
Is Cloudflare Turnstile free?
Turnstile has a free plan that covers most sites. You need a Cloudflare account to create a widget and get the site key and secret key.
Do I have to verify a captcha token on the server?
Yes. The token proves nothing until your server sends it, with your secret key, to the provider's verify endpoint and gets a success answer. Without that step, bots can submit with any token or none.
Which captcha is best for user experience?
Invisible or single-checkbox options such as Turnstile or reCAPTCHA v3 interrupt real users the least. Combine them with a honeypot, a time check and rate limits so the captcha rarely has to challenge anyone.

