Your user list jumped overnight. The new accounts have random-looking addresses, none of them ever logged in, and the auth email quota ran dry, so real customers stopped getting confirmation links. Or someone you have never heard of wrote in to ask why your app sent them a “confirm your signup” message.
This guide is for apps on Supabase Auth, including apps built in Lovable or Bolt. It explains why a widget on the form is not enough, how to switch on Supabase’s own CAPTCHA check without locking out real users, which auth calls need the token, what to add around it, and how to remove the junk accounts without deleting real ones. Supabase help: /fix/supabase.
Why bots skip your signup form
A Supabase frontend talks to the Auth API directly. When your page runs supabase.auth.signUp(...), the browser sends a request to https://<project-ref>.supabase.co/auth/v1/signup with your project’s public (anon or publishable) key. That URL and key ship inside your JavaScript, so a script can send the same request without ever loading your page.
That has two consequences:
- Anything that lives only in the page does nothing against a script. A disabled button, a “required” checkbox, a hidden honeypot field, even a CAPTCHA widget whose token nobody checks: the bot never renders the form.
- The check has to run on the server. Either Supabase Auth verifies a CAPTCHA token on its side, or the signup goes through a server function you control.
Cloudflare’s Turnstile docs make the same point about their own product: the widget in the browser has to be paired with a server-side call to their verification API, or the form is not protected (Turnstile server-side validation). Supabase’s CAPTCHA setting is that server-side call, made for you on each protected auth request.
What bot signups look like in Supabase
Before changing settings, confirm the pattern. Run this in the SQL Editor to see signups per day and the number never confirmed:
select date_trunc('day', created_at) as day,
count(*) as signups,
count(*) filter (where email_confirmed_at is null) as unconfirmed,
count(*) filter (where last_sign_in_at is null) as never_signed_in
from auth.users
where created_at > now() - interval '30 days'
group by 1
order by 1 desc;
And this to see which email domains the new accounts use:
select lower(split_part(email, '@', 2)) as domain, count(*)
from auth.users
where created_at > now() - interval '7 days'
and email is not null
group by 1
order by 2 desc
limit 25;
Signs that point at automation rather than a launch going well: a spike that matches no marketing push, a high unconfirmed share, accounts that never signed in, clusters of one throwaway domain, and email rate limit exceeded showing up in your Auth logs. Supabase’s SMTP guide describes bots that register lists of real addresses to damage your sending reputation or deny service to real signups, sometimes slowly over months and sometimes in one burst (custom SMTP). On Lovable’s built-in backend, the Users view has a Signups chart covering a week, a month or a quarter (7, 30 or 90 days) (Lovable: users and authentication).
If the email quota is the visible symptom, Supabase confirmation email not sending covers the sending side.
Layer 1: CAPTCHA enforced by Supabase Auth
Supabase Auth supports two providers: hCaptcha and Cloudflare Turnstile. Setting up a site with either provider produces two values: a public site key for your frontend and a private secret key that only Supabase should hold. In the Supabase dashboard, open the project’s Authentication settings, find the Bot and Abuse Protection section, turn on the Enable CAPTCHA protection switch, pick the provider and paste the secret (Supabase: CAPTCHA protection).
Once that switch is on, Supabase verifies the token with the provider before it handles the request. A request that has no token is refused with captcha protection: request disallowed (no captcha_token found), and a token the provider rejects fails with the error code captcha_failed (Supabase Auth source: middleware.go; Auth error codes). That covers bots calling the API directly too, because the check lives in Auth, not in your page.
Two details for the Turnstile setup:
- Hostnames. Every Turnstile widget needs at least one allowed hostname, and adding a hostname also allows its subdomains. Wildcards, schemes, ports and paths are not accepted (Turnstile hostname management). List your production domain and any preview or staging domain you test on, or the widget will not run there.
- Mode. Turnstile widgets come in Managed, Non-Interactive and Invisible modes; Cloudflare recommends Managed, which decides per visitor whether to show a checkbox (Turnstile widget types).
Ship the widget first, then turn enforcement on
Order matters here. The moment enforcement is on, every protected call without a token fails, including calls from your own live site if the new code is not deployed yet. Real users then see sign-in errors while you scramble.
Supabase only reads the token when CAPTCHA protection is enabled; with the setting off, the check returns early and the token is ignored (Supabase Auth source: middleware.go). So you can deploy the frontend change safely first:
- Create the Turnstile or hCaptcha site and note both keys.
- Add the widget to every auth form (list below) and pass its token on each call. Publish.
- On the live site, open the browser’s Network tab, submit the signup form and click the request to
/auth/v1/signup. The request body should containgotrue_meta_securitywith acaptcha_tokenvalue. Repeat for login and password reset. - Only now paste the secret key into Supabase and turn on Enable CAPTCHA protection.
- Test every flow again in a private window: sign up, log in, wrong password then right password, forgot password, magic link.
If something breaks after step 4, turning the setting off again restores the old behaviour while you fix the form.
Every call that needs captchaToken
This is where AI-generated apps trip. The builder adds the widget to the signup page and forgets the four other places that call Auth. With enforcement on, Supabase Auth checks the token on these endpoints (Supabase Auth source: api.go), and each matching supabase-js method takes a captchaToken option (supabase-js auth types):
| supabase-js call | Where the token goes |
|---|---|
signUp (email or phone) | options: { captchaToken } |
signInWithPassword | options: { captchaToken } |
signInWithOtp (magic link or code) | options: { captchaToken } |
resetPasswordForEmail | second argument: { captchaToken, redirectTo } |
resend (confirmation email again) | options: { captchaToken } |
signInAnonymously (if you allow guests) | options: { captchaToken } |
signInWithSSO, Web3 and passkey sign-in | options: { captchaToken } |
Calls that do not need a token: signInWithOAuth (Google, GitHub and other social buttons), verifyOtp, token refresh, the PKCE code exchange after a redirect, and signInWithIdToken. Auth does not run the check on those endpoints and grant types. Server-side calls made with the service role key also skip it, so an admin script or Edge Function that creates users is not affected.
A minimal React pattern with Turnstile, written to reset the widget after every attempt:
import { useRef, useState } from 'react'
import { Turnstile, type TurnstileInstance } from '@marsidev/react-turnstile'
import { supabase } from '@/integrations/supabase/client'
export function SignUpForm() {
const widget = useRef<TurnstileInstance>(null)
const [token, setToken] = useState<string | null>(null)
async function handleSubmit(email: string, password: string) {
if (!token) return
const { error } = await supabase.auth.signUp({
email,
password,
options: { captchaToken: token },
})
// A token can be redeemed once. Get a fresh one for the next attempt.
widget.current?.reset()
setToken(null)
if (error) {
// show error.message to the user
}
}
return (
<>
{/* your email and password inputs, calling handleSubmit */}
<Turnstile
ref={widget}
siteKey={import.meta.env.VITE_TURNSTILE_SITE_KEY}
onSuccess={setToken}
onExpire={() => setToken(null)}
/>
</>
)
}
The import path for the Supabase client differs per project; keep whatever your app already uses. Supabase’s own examples use the @marsidev/react-turnstile and @hcaptcha/react-hcaptcha packages, and its hCaptcha example resets the challenge once the auth call returns (Supabase: CAPTCHA protection).
A prompt for Lovable or Bolt
If the app is connected to a Supabase project you own, you can hand the frontend change to the builder. Paste your real site key, never the secret:
Add Cloudflare Turnstile to every authentication form in this app.
Site key: <your site key>. Use the @marsidev/react-turnstile package.
Pass the token as options.captchaToken on every call to supabase.auth.signUp,
signInWithPassword, signInWithOtp, resend and signInAnonymously, and as
captchaToken in the options of resetPasswordForEmail.
Reset the widget and clear the token after every call, whether it succeeds or fails.
Disable the submit button until a token exists.
Do not change signInWithOAuth or any Supabase settings.
When done, list every file and every auth call you changed.
Check the list it returns against the table above before you flip the switch in Supabase.
If your app runs on Lovable Cloud or Bolt Database
The dashboard toggle above belongs to a Supabase project you can open. Lovable’s built-in backend documents two sign-up controls, Disable sign-up and Enable anonymous users, plus one auth rate limit you can change yourself (the email sending limit); its authentication docs do not describe a CAPTCHA setting (Lovable: users and authentication). Bolt’s database authentication page lists email signup, confirmation and password settings but no CAPTCHA option either (Bolt: authentication). Check your project’s auth settings in case this has changed since this guide was written.
Without the native setting, the server-side check has to live in your own code:
- Invite-only or beta apps: turn on Disable sign-up. Existing users keep signing in, and Lovable’s docs note you can still create accounts with Add user (Lovable: users and authentication).
- Public signups: route signup through an Edge Function. The function verifies the Turnstile token with Cloudflare’s Siteverify endpoint using the secret stored as a backend secret (Lovable Cloud has a Secrets area for this, per Lovable Cloud), and only then creates the account with
auth.admin.inviteUserByEmail, which emails the person a link to join (Turnstile server-side validation; inviteUserByEmail). Then turn on Disable sign-up so the public/signupendpoint is closed; in Supabase Auth’s code the disabled-signup check sits in the public signup handler, not in the admin user endpoints (Supabase Auth source: signup.go). Avoidauth.admin.createUserfor public signups: it does not send a confirmation email, and passingemail_confirm: trueskips proof that the address belongs to the person (createUser; supabase-js admin source).
This route only protects signup. Password login and password reset stay open to scripts unless you wrap them the same way, which is a bigger change. If you would rather use the native toggle, moving to your own Supabase project is covered in migrate from Lovable Cloud to Supabase; on Bolt, claiming the database to Supabase or connecting your own project gives you a Supabase dashboard (Bolt: authentication).
Layer 2: rate limits and email confirmation
CAPTCHA raises the cost of each fake account. Rate limits cap how fast any one source can go. Supabase Auth’s defaults, from its rate limits page (Supabase: rate limits):
- Sign-ups and sign-ins (
/signup,/recover,/resend,/magiclink,/otp): 30 requests per 5 minutes per IP address, with bursts up to 30. Customizable. - Emails sent by Auth: 2 per hour for the whole project on the built-in email provider. Configurable once you use custom SMTP or a Send Email hook.
- Anonymous sign-ins: 30 per hour per IP address. Customizable.
- Per user: a 60-second wait before the same user can request another confirmation, reset or magic link.
Change them under Authentication → Rate Limits. Exceeding a limit returns 429 Too Many Requests.
If you route signups through your own server or Edge Function, every request reaches Supabase from that server’s address, so the per-IP limit applies to all your users at once. Supabase supports forwarding the real client address in an Sb-Forwarded-For header, sent with a secret key, after you enable IP address forwarding in the same Rate Limits page (Supabase: rate limits).
Keep Confirm email on. Supabase lists pressuring owners into switching confirmation off as one of the aims of signup abuse, because it lets an attacker create accounts under someone else’s address (custom SMTP). With confirmation off, Supabase also marks every new address as confirmed, which removes your easiest signal for spotting junk later (Supabase: general configuration).
Layer 3: block domains with a signup hook
Supabase’s Before User Created hook runs just before an account is inserted and can refuse it. Supabase names blocking disposable email domains and restricting by IP as uses for it, and the hook is listed for the Free and Pro plans (Before User Created hook; Auth Hooks).
A small Postgres version that refuses domains you add to a table:
create table public.blocked_signup_domains (domain text primary key);
alter table public.blocked_signup_domains enable row level security;
create policy "auth admin can read blocked domains"
on public.blocked_signup_domains for select
to supabase_auth_admin using (true);
create or replace function public.block_signup_domains(event jsonb)
returns jsonb
language plpgsql
as $$
begin
if exists (
select 1 from public.blocked_signup_domains b
where b.domain = lower(split_part(event->'user'->>'email', '@', 2))
) then
return jsonb_build_object('error', jsonb_build_object(
'http_code', 403,
'message', 'Please sign up with a different email address.'));
end if;
return '{}'::jsonb;
end;
$$;
grant usage on schema public to supabase_auth_admin;
grant select on public.blocked_signup_domains to supabase_auth_admin;
grant execute on function public.block_signup_domains to supabase_auth_admin;
revoke execute on function public.block_signup_domains from authenticated, anon, public;
Then pick the function under Authentication → Hooks for Before User Created. Fill the table from the domain query earlier, one row per domain you have seen abused. The hook also runs for social sign-ins, so do not add a domain that real customers use. Supabase’s hook page has longer examples, including allow lists and IP ranges.
Contact and waitlist forms outside Supabase Auth
A contact or waitlist form that inserts straight into a table with the public key has the same weakness as signup: a script can post the insert without your page. Supabase’s CAPTCHA setting does not cover table inserts, so:
- Send the form to an Edge Function instead of inserting from the browser.
- In the function, call Turnstile’s Siteverify endpoint with your secret and the token. Reject when
successis false. Tokens last 300 seconds and can be redeemed once (Turnstile server-side validation). - Insert with a server-side client, and remove the insert policy that let
anonwrite to the table directly. Supabase RLS policies explained shows how to check whatanoncan do.
A honeypot fits here too, because the form now posts to code you control: add a field that CSS hides from human visitors, and have the function drop any submission where that field is filled in. It is a cheap extra filter for scripts that fill every field. It does nothing on its own for a form that calls Supabase straight from the browser, since a bot calling the API never sees the field.
Clean up the accounts already created
Export before you delete. Supabase’s user management docs show select * from auth.users; in the SQL Editor, with results exportable as CSV (managing user data).
Look at candidates first. This lists email accounts that never confirmed and never signed in, older than two days so genuine new signups still have time to click their link. The invited_at line keeps out invitations that have not been accepted yet:
select id, email, created_at
from auth.users
where email is not null
and email_confirmed_at is null
and last_sign_in_at is null
and invited_at is null
and created_at < now() - interval '2 days'
order by created_at desc;
Read through the results. If they all look like junk, delete them with the same filter. This is permanent; your export is the only copy afterwards:
delete from auth.users
where email is not null
and email_confirmed_at is null
and last_sign_in_at is null
and invited_at is null
and created_at < now() - interval '2 days';
Points to know before you run it:
- Rows in your own tables that reference
auth.userswithon delete cascadego with the user. Supabase’s docs recommend that reference for profile tables (managing user data). - A user who owns files in Storage cannot be deleted until those objects are removed or reassigned.
- Deleting a user does not cut off an access token already issued; it stays valid until it expires.
- For guest accounts, Supabase’s anonymous sign-in page shows deleting
is_anonymoususers past an age you choose, since there is no automatic cleanup (anonymous sign-ins).
For a handful of accounts, the dashboard’s Authentication → Users page or auth.admin.deleteUser from a server works too.
What not to do
- Do not switch off Confirm email to save your email quota. That is the outcome Supabase’s SMTP guide warns attackers push for. Fix sending with custom SMTP instead.
- Do not rely on a hidden field or a front-end-only widget. Neither runs when a script calls the API.
- Do not paste the CAPTCHA secret key into frontend code or a
VITE_variable. It belongs in Supabase’s setting or a backend secret. If it has leaked, rotate it; see API key leaked: what to do. - Do not block whole countries or networks as the first move. The hook can deny IP ranges, but a broad block also turns away real customers on those networks. Target the specific addresses and domains you have evidence for.
- Do not leave test keys in production. Turnstile and hCaptcha publish dummy keys that always pass; hCaptcha’s docs note they give no protection against bots (Turnstile testing; hCaptcha docs).
Bot signups are also a sign that scripts are probing the rest of the app. The vibe-coded app security checklist and the production readiness guide cover the other doors.
FAQ
Which is better, Turnstile or hCaptcha?
Supabase Auth supports both; the setup steps differ only in where you copy the keys and which React component you install (Supabase: CAPTCHA protection). Turnstile’s Managed mode never asks visitors to decipher images or text (Turnstile widget types), and Supabase’s SMTP guide points to invisible challenges as a way to keep friction low for real users (custom SMTP). Pick the one whose dashboard and privacy terms suit you; the Supabase side works the same.
Why do real users get a CAPTCHA error after I enabled it?
Supabase’s message starts with captcha protection: request disallowed, followed in brackets by the reason, and the error code is captcha_failed. Check these in order:
- A form still sends no token. The error then says
no captcha_token found. Find the call in the table above that was missed. - The token was reused. After a wrong password, the same token is spent. Turnstile reports
timeout-or-duplicate, which shows up inside the brackets of Supabase’s message, for reused or expired tokens (Turnstile server-side validation). Reset the widget after every attempt. - The token expired. Turnstile tokens are valid for 300 seconds, so a user who filled the form slowly needs a fresh one. Clear the token in the widget’s expire callback.
- Keys from two different sites. Your frontend’s site key and the secret pasted into Supabase must come from the same widget.
- The domain is not allowed. The widget will not run on a hostname missing from its list, such as a new preview URL.
- Test keys are still configured on one side but not the other.
Will this stop bots that call the API directly?
It stops any request lacking a valid token, whether it comes from your page or a script, because Supabase Auth does the check. It does not stop a person, or a paid solving service, completing the challenge and then signing up. That is why the rate limits, the signup hook and confirmation stay in place behind it.
Can I delete the fake users?
Yes. Export first, select with a filter on unconfirmed and never-signed-in accounts older than a couple of days, review, then delete with the same filter, as shown above. If a bot used someone else’s real address, that person already received a confirmation message; deleting the account cannot recall it.
Do I need this on a waitlist form with no login?
Supabase’s CAPTCHA setting does not apply there, because no auth call is involved. If the form inserts into a table with the public key, a script can fill that table. Use the Edge Function plus Siteverify pattern from the contact form section.
Does CAPTCHA break Google sign-in?
No. signInWithOAuth goes through the provider’s redirect, and the code exchange that follows is one of the grant types Auth skips (Supabase Auth source: middleware.go). Only the email, phone, magic link, anonymous, SSO, Web3 and passkey calls listed above need the token.
Comments