How do I block disposable emails with Clerk in Next.js?
Do two things. First turn on Clerk's own disposable-email protection, which is free on every plan and off by default. Then add a user.created webhook that checks each new account's email with Disban and bans the account when the domain is disposable or a testing inbox. The webhook runs on your server, so it can't be skipped by someone calling Clerk directly from a script, and it needs no API key to start.
Start with Clerk's own setting
Clerk includes a "Block disposable email addresses" protection on every plan. It is off by default, so check your dashboard's protection settings. It blocks domains Clerk already knows are disposable, at sign-up and when someone adds an email to an existing account; it doesn't affect sign-in. A broader "Block risky email domains" protection needs Clerk's Business plan. Disban adds what a fixed list can't: new domains on mail servers known to run disposable inboxes, domains that can't receive mail at all, and an unknown category you can hold rather than block. Every answer also says why.
The webhook: the check that can't be skipped
In the Clerk dashboard, add a webhook endpoint for user.created pointing at this route, and put its signing secret in CLERK_WEBHOOK_SIGNING_SECRET. If your middleware protects routes, leave /api/webhooks public: webhooks carry no session. Clerk sends user.created once the sign-up is complete, so the address has already received the verification code; banning signs the account out and stops it signing in again.
npm install disban
// app/api/webhooks/clerk/route.ts
import { verifyWebhook } from "@clerk/nextjs/webhooks";
import { clerkClient } from "@clerk/nextjs/server";
import type { NextRequest } from "next/server";
import { signupDecision } from "disban";
export async function POST(req: NextRequest) {
let evt;
try {
evt = await verifyWebhook(req); // reads CLERK_WEBHOOK_SIGNING_SECRET
} catch {
return new Response("Invalid signature", { status: 400 });
}
if (evt.type !== "user.created") return new Response("ok");
const user = evt.data;
const email = user.email_addresses.find((e) => e.id === user.primary_email_address_id)?.email_address;
if (!email) return new Response("ok");
const d = await signupDecision(email);
const clerk = await clerkClient();
if (d.action === "block") {
await clerk.users.banUser(user.id);
} else if (d.action === "allow" && d.hold) {
// unknown domain, or Disban was unreachable: keep the account, hold free credits until you trust it
await clerk.users.updateUserMetadata(user.id, { privateMetadata: { holdCredits: true } });
}
return new Response("ok");
}A friendlier message on a custom sign-up form
With Clerk's prebuilt SignUp component, the webhook is the whole integration. If you built your own form with useSignUp, you can also check the address before calling signUp.create, so people see a clear message instead of a banned account. Keep the webhook as well: the browser talks to Clerk directly, so this check is for the message, not for security.
// app/sign-up/check-email.ts
"use server";
import { signupDecision } from "disban";
export async function checkEmail(email: string) {
const d = await signupDecision(email);
if (d.action === "block") return "Please use a permanent email address.";
if (d.action === "fix") return "This email domain can't receive mail. Check the address.";
return null;
}
// in your sign-up form, just before your existing signUp.create(...) call
const problem = await checkEmail(emailAddress);
if (problem) return setError(problem);Production: add a free API key
The keyless endpoint allows 10 checks per hour and 30 per day per network, which is enough to try this but not for real sign-up traffic. Set DISBAN_API_KEY (free, 2,000 checks a month, no card) in your hosting provider's environment variables and the same code uses the keyed API with full evidence. Never prefix it with NEXT_PUBLIC_.
npx disban signup # name, email, 6-digit code: prints your key
# .env.local
DISBAN_API_KEY=dbn_...
CLERK_WEBHOOK_SIGNING_SECRET=whsec_...What gets blocked, and what doesn't
signupDecision blocks the disposable and testing categories. Free providers such as Gmail and Outlook are allowed, and so are privacy relays such as SimpleLogin, Firefox Relay and Apple Hide My Email (category alias), because a real person reads them. fix means the domain has no working mail route; on the webhook it rarely happens, because Clerk has already delivered a code to the address.
When Disban is slow or down
signupDecision never locks real people out. If Disban is slow, rate-limited or unreachable, it returns allow with hold set to true, so the account is created and the webhook marks it to hold free credits. Clerk retries webhooks that fail, so return 200 once you've handled the event, even when you chose to do nothing.
Source for provider behavior: Clerk: Block disposable email addresses. Product-policy guidance is Disban's interpretation.