How do I block disposable emails in Next.js?
Check the email on the server, inside the route handler or Server Action that creates the account, before you send a verification email. Install the disban package, call signupDecision(email), and stop when the action is block (a disposable or test inbox) or fix (a domain that cannot receive mail). It needs no API key to start, has no dependencies, and runs on the Node.js and Edge runtimes.
Try it first, without a key
The package calls Disban's keyless endpoint, so you can see a real answer before signing up for anything.
npm install disban
curl https://disban.io/api/v1/check/yopmail.com
# {"domain":"yopmail.com","category":"disposable","disposable":true,"mail_routing":"routable"}App Router route handler
Put the check at the top of the POST handler. Return a message the person can act on, rather than an accusation.
// app/api/signup/route.ts
import { signupDecision } from "disban";
export async function POST(request: Request) {
const { email } = await request.json();
const d = await signupDecision(email);
if (d.action === "block")
return Response.json({ error: "Please use a permanent email address." }, { status: 400 });
if (d.action === "fix")
return Response.json({ error: "This email domain can't receive mail. Check the address." }, { status: 400 });
// d.action === "allow". d.hold is true for unknown domains or when Disban was unreachable:
// create the account, but hold free credits until the email is confirmed.
const user = await createUser({ email, holdCredits: d.hold });
return Response.json({ ok: true, id: user.id });
}Server Action version
The same call works in a Server Action, which is common for signup forms built with useActionState.
// app/signup/actions.ts
"use server";
import { signupDecision } from "disban";
export async function signUp(_: unknown, form: FormData) {
const email = String(form.get("email") ?? "");
const d = await signupDecision(email);
if (d.action === "block") return { error: "Please use a permanent email address." };
if (d.action === "fix") return { error: "This email domain can't receive mail. Check the address." };
await createUser({ email, holdCredits: d.hold });
return { ok: true };
}Production: add a free API key
The keyless endpoint allows 10 checks per hour and 30 per day per network; set DISBAN_API_KEY (free, 2,000 checks a month, no card) and the same code switches to the keyed API with full evidence. Add it in your hosting provider's environment variables (Vercel: Project Settings, Environment Variables) and never expose it to the browser: do not prefix it with NEXT_PUBLIC_.
npx disban signup # name, email, 6-digit code: prints your key
# .env.local
DISBAN_API_KEY=dbn_...What it blocks and what it lets through
Disban classifies the domain into one of six categories. block covers disposable and testing inboxes. Free providers such as Gmail and Outlook are allowed. Privacy relays such as SimpleLogin, Firefox Relay and Apple Hide My Email are category alias and are allowed by default, because a real person reads them. Domains with no working mail route return fix, which also catches typos like gmial.com before your verification email bounces.
Handling unknown results and outages
signupDecision never locks real users out. If Disban is slow, rate-limited or unreachable it returns allow with hold: true, so you can create the account but hold free credits or rewards until the email is confirmed. Do not run the check in middleware for every request: one call per signup is enough, and middleware would spend your quota on page views.
Source for provider behavior: Disban API documentation. Product-policy guidance is Disban's interpretation.