Article

Email Validation in React Hook Form: Format Rules, Zod, and Server Mailbox Checks

By Unlimited Verifier Team ·

Diagram of React Hook Form email validation showing browser format checks, a server-side mailbox check for email validation, and a confirmation email step.

Summary

To validate email in React Hook Form, register a format rule such as a pattern, a validate function, or a Zod schema via zodResolver. Then add a mailbox check on your own server route, since lookups need an API key and network access that must stay out of the browser.

To validate email in React Hook Form, attach a format rule to the field with register, using a pattern, a validate function or a Zod schema through zodResolver, then add a mailbox check that calls your own server route. Format rules run instantly in the browser. Mailbox checks must run on the server, because they need an API key and a network lookup that should never reach the browser.

This page covers the React-specific wiring. For the broader strategy, read our pillar on real-time email validation.

Quick answer

What can React Hook Form validate on an email field, and what can't it?

React Hook Form has no built-in email type. It runs the rules you register, shows the error message and blocks submission until they pass. Those rules execute in the browser, so they can confirm an address looks right, but not that the mailbox exists.

Layer Where it runs What it catches What it cannot tell you
HTML type="email" plus required Browser Empty fields and obvious malformations The WHATWG HTML Standard defines a deliberately loose email grammar, so some invalid-looking addresses pass
pattern rule Browser Format rules you define Whether the mailbox exists
Zod or Yup schema via a resolver Browser, or shared with the server Format, length, trimming Whether the mailbox exists
Async check through your API route Server Nonexistent mailboxes, dead domains, disposable and role addresses, catch-all flags Whether a catch-all domain actually delivers to that person
Confirmation email Mail system Control of the inbox Intent, which needs opt-in records

Bottom line: Use the browser for fast format feedback and the server for anything that needs a network lookup.

Why isn't a regex enough for email validation?

A regex can reject typos that could never be delivered, but it cannot decide whether an address is real. Overly strict patterns cause more damage than loose ones, because they block legitimate customers.

Specification and practice diverge in three places:

Our recommendation is a lenient pattern: one @, no whitespace, non-empty local and domain parts, and a dot in the domain. Leave deliverability judgments to the mailbox check. If you need the broader JavaScript picture, how to validate email in JavaScript covers the same trade-offs outside React.

const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;

Bottom line: Your regex should catch what cannot be delivered, not guess what is valid.

How do you add email format validation with register?

Add required and pattern rules to the register call, and set aria-invalid so screen readers announce the error. Trim whitespace before you send, because the pattern rejects embedded spaces.

import { useForm } from 'react-hook-form';

const EMAIL_PATTERN = /^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/;

export default function SignupForm() {
  const {
    register,
    handleSubmit,
    formState: { errors },
  } = useForm({ mode: 'onBlur' });

  const onSubmit = (values) => {
    const email = values.email.trim().toLowerCase();
    // send to your signup endpoint
  };

  return (
    <form onSubmit={handleSubmit(onSubmit)} noValidate>
      <label htmlFor="email">Work email</label>
      <input
        id="email"
        type="email"
        aria-invalid={errors.email ? 'true' : 'false'}
        {...register('email', {
          required: 'Enter your email address',
          pattern: {
            value: EMAIL_PATTERN,
            message: 'Check the format, for example name@company.com',
          },
        })}
      />
      {errors.email && <p role="alert">{errors.email.message}</p>}
      <button type="submit">Create account</button>
    </form>
  );
}

The noValidate attribute stops the browser's native popups from competing with your messages. Lowercasing is safe for the domain. The local part is technically case-sensitive under the RFCs, but most providers treat it as case-insensitive, so store the address as typed and compare normalised copies.

Note that handleSubmit runs every registered rule again on submit, not only the ones that already fired on blur. That matters once you add an async check, covered below.

Bottom line: A pattern rule plus aria-invalid gives instant, accessible format feedback at zero network cost.

How do you validate email with a Zod schema?

Define the format in a Zod schema, connect it with zodResolver from @hookform/resolvers, and keep network calls out of the schema. The schema stays synchronous, easy to unit test, and reusable on the server.

import { useForm } from 'react-hook-form';
import { zodResolver } from '@hookform/resolvers/zod';
import { z } from 'zod';

const schema = z.object({
  email: z
    .string()
    .trim()
    .min(3, 'Enter your email address')
    .max(254, 'That address is too long')
    .email('Check the format, for example name@company.com'),
});

export default function SignupForm() {
  const { register, handleSubmit, setError, formState: { errors, isSubmitting } } =
    useForm({ resolver: zodResolver(schema), mode: 'onBlur' });

  const onSubmit = async (values) => {
    const res = await fetch('/api/verify-email', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ email: values.email }),
    });
    const { status } = await res.json();
    if (status === 'invalid') {
      setError('email', { type: 'manual', message: 'This mailbox does not appear to exist' });
      return;
    }
    // continue to account creation
  };

  return (
    <form onSubmit={handleSubmit(onSubmit)} noValidate>
      <input type="email" {...register('email')} aria-invalid={errors.email ? 'true' : 'false'} />
      {errors.email && <p role="alert">{errors.email.message}</p>}
      <button type="submit" disabled={isSubmitting}>Create account</button>
    </form>
  );
}

Two gotchas. First, when you pass a resolver, React Hook Form uses the schema for validation and ignores the register rules, so put every rule in one place. Second, @hookform/resolvers also supports Yup and Joi, so the same pattern works if your team already uses them. Zod 4 recommends the top-level z.email() over z.string().email(), so check the version you have installed. Full documentation is on zod.dev and react-hook-form.com.

Bottom line: Use a resolver for synchronous format rules, and run the mailbox check after them.

Why must the mailbox check run on the server?

The mailbox check has to run on a server for two reasons. Browsers cannot open raw SMTP connections, so the browser has no way to ask a mail host whether a recipient exists. And the verification API needs a key, which anyone can read from client code.

Any key placed in client code, including a NEXT_PUBLIC_ variable, is visible in the browser's developer tools. Anyone who finds it can run up your verification bill or reuse it for their own lists. Your server also gives you a place to cache results, rate-limit requests and log outcomes. Our guide to client-side vs server-side email validation explains why both layers are needed.

Bottom line: The browser asks your server, and only your server holds the key.

How do you build the server route that checks a mailbox?

Create one route that accepts an address, checks the cache, calls the verification API and returns a simple status. The example below uses Next.js App Router. The endpoint URL and auth header are placeholders, so take the real values from the Email verification API documentation.

// app/api/verify-email/route.js
const cache = new Map(); // placeholder: use Redis or your database in production
const TTL_MS = 24 * 60 * 60 * 1000;

export async function POST(request) {
  const { email } = await request.json();
  const address = String(email ?? '').trim().toLowerCase();
  if (address.length < 3 || address.length > 254 || !address.includes('@')) {
    return Response.json({ status: 'invalid' });
  }

  const hit = cache.get(address);
  if (hit && Date.now() - hit.at < TTL_MS) {
    return Response.json({ status: hit.status });
  }

  const res = await fetch(process.env.UV_VERIFY_URL, {   // placeholder: endpoint from the API docs
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.UV_API_KEY}`, // placeholder: auth scheme from the API docs
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ email: address }),
  });
  const data = await res.json();
  const status = mapToStatus(data); // placeholder: map the Valid, Risky or Invalid field named in the docs

  cache.set(address, { status, at: Date.now() });
  return Response.json({ status });
}

Three design points matter here. The Free plan has no API access, so production checks need a Pro subscription. Results on the platform are kept for limited periods (24 hours on Free and 30 days on Pro), so your own cache and log become the record you keep. And an in-memory Map resets whenever a serverless instance restarts and is not shared between instances, which is why production systems move the cache to shared storage.

The same route shape works in Express, Remix or any backend that can call an API. If your backend is in another language, see email validation in Java Spring Boot or our Golang email validation packages guide. The pattern also extends to batch and scheduled jobs, which is the core of email verification API and automation.

Bottom line: One server route owns the key, the cache and the logic, so every form can share them.

How do you call the mailbox check from the form without blocking users?

Attach the async check as a validate rule, and make it fail open. If the verifier is slow or down, the form accepts the address and the confirmation email covers the gap.

const checkMailbox = async (value) => {
  try {
    const res = await fetch('/api/verify-email', {
      method: 'POST',
      headers: { 'Content-Type': 'application/json' },
      body: JSON.stringify({ email: value.trim() }),
    });
    const { status } = await res.json();
    if (status === 'invalid') return 'This mailbox does not appear to exist';
    return true;
  } catch {
    return true; // fail open; the confirmation email is the backstop
  }
};

// inside register:
// {...register('email', { required: '...', pattern: {...}, validate: checkMailbox })}

Failing open is a deliberate trade-off. During an outage, an invalid address can get through the form, so the confirmation step must catch it. Failing closed would stop real customers from signing up whenever the vendor has a bad minute.

Bottom line: Fail open on errors, and let confirmation email protect the account when the check is unavailable.

When should React Hook Form run validation: onBlur, onChange or onSubmit?

Use mode: 'onBlur' for network-backed checks. It runs validation when the user leaves the field, which gives one verification request per completed entry. onChange runs on every keystroke, which multiplies requests.

Mode When rules run Network checks per address (typical) Verdict for mailbox checks
onSubmit (default) Only on submit One, at submit Safe, but users see errors late
onBlur When the field loses focus One per completed entry, plus one on submit Recommended, with caching
onChange Every keystroke Up to one per character typed Avoid for network calls
onTouched First blur, then every change Several per entry Usually more than you need
all Blur and change Several per entry Avoid

The submit rerun is the detail teams miss. A blur check followed by handleSubmit sends a second request for the same address unless your cache answers it. That is why the route caches by normalised address before you tune anything else.

reValidateMode controls behaviour after the first submit. Keep it as 'onBlur' for network checks, so a corrected address is rechecked only when the user moves on.

Bottom line: Blur-triggered validation with a server cache gives the same feedback with a fraction of the requests.

What does a mailbox check actually test, and how reliable is it?

A mailbox check asks the recipient's mail server whether it would accept mail for the address, then disconnects without sending a message. The verifier connects, announces itself, requests the recipient, and reads the response code. The result depends on that response.

Two limits follow. A Valid result is a snapshot: a mailbox can close the day after you check it. And some mail providers restrict or block verification probes, which is why why SMTP email verification gets blocked is worth reading before you build your own checker.

Unlimited Verifier's documentation describes its checks as covering syntax, domain, MX records and the SMTP mailbox, with catch-all detection. That combination is what makes the Risky bucket useful.

Bottom line: A mailbox check is strong evidence about an address at one moment, not a guarantee for the life of the account.

How do you keep verification requests under control?

Gate, cache and rate-limit before you think about scale. These three steps prevent most of the cost and abuse problems teams report.

  1. Gate on format first. Call the API only when the regex and length checks pass.
  2. Cache by normalised address. Repeat entries, including the submit rerun, should cost nothing. Store the status and timestamp.
  3. Rate-limit your route. Cap requests per IP or session, so a script cannot use your endpoint to probe addresses.
  4. Respect the vendor's limits. Check the rate limits in the API documentation, and back off on errors. Our guide to email validation API rate limits covers retry patterns.

Bottom line: Gate, cache and rate-limit, in that order.

How should your form handle Valid, Risky and Invalid results?

Block Invalid addresses, accept Valid ones, and treat Risky results as a business decision. Risky does not mean wrong. It means the check could not confirm the mailbox with the certainty that Valid implies.

Result Form behaviour Why
Valid Accept The mailbox passed the checks
Invalid Block, with a clear message Mail to this address will bounce
Risky: catch-all domain Accept, then confirm by email The domain accepts any local part, so the mailbox cannot be confirmed. See catch-all email verification
Risky: disposable Block for free trials, accept for content downloads Throwaway addresses rarely convert
Risky: role-based (info@, sales@) Accept for B2B, flag for sales Shared inboxes can be valid but rarely belong to one buyer

Catch-all is the case most teams get wrong. Because a catch-all domain accepts mail for any address, a passing result says little about the specific person. Blocking those signups turns away real customers, so send a confirmation email instead. Blocking too many Risky addresses also reduces reach, which is why the acquisition side matters too; our guide to email list growth strategies covers it.

Bottom line: Block Invalid, accept Valid, and let a confirmation email settle the Risky cases.

Which validation approach should you choose?

For most SaaS signup forms, a Zod schema, a blur-triggered mailbox check through your route and a confirmation email together give the best balance. Simpler forms can drop the network check, and high-value lead forms justify keeping it.

Approach Best for Trade-off
register rules only Newsletters with double opt-in Lets typos and dead domains through
Zod schema, checked at submit Low-cost signup forms No mailbox check
Blur-triggered async check via your route Trials, lead forms, anywhere a bad address costs money More requests; needs caching
Build your own DNS and SMTP checks Teams with deep infrastructure expertise You must run your own MX record checks, and outbound SMTP from servers is often blocked by providers
Bulk verification of an existing list Cleaning databases you already have Not inline; batch the file

For teams running email verification for ecommerce and SaaS, the trade-off is usually about signup friction versus bad data. For format-only checks in Node, see our guide to the best Node.js email validation libraries. For a wider comparison of providers, see best email verification tools and our vendor comparison.

Bottom line: Pick the lightest approach that protects the places where a bad address costs you most.

How do you clean an existing list before it reaches the form?

Clean existing lists with bulk verification, not inside the form. Export a CSV, verify it, and re-import only the Valid contacts. Unlimited Verifier has no native React, ESP or CRM integration, so this export-verify-re-import loop, or a direct API call from your own scripts, is the workflow.

The plan limits decide how many files you need. On Free, each list holds up to 150 emails and you get 25 lists a month, which caps you at 3,750 emails a month. Cleaning 48,000 contacts would need 320 lists (48,000 ÷ 150 = 320), about 13 months of Free allowance. On Pro, each list holds up to 25,000 emails and lists are unlimited, so the same 48,000 contacts fit in two files: 25,000 + 23,000.

Standard verification is unlimited on every plan, so re-checking a file costs nothing extra. Deep verifications are a separate monthly quota (750 on Free, 25,000 on Pro). Use upload and verify a list to start a batch; CSV and Excel files up to 10MB are accepted.

For ongoing hygiene, schedule re-verification rather than running a one-off clean. Our guide to email list maintenance best practices covers the cadence, and email verification for sales prospecting explains why B2B addresses decay quickly.

Bottom line: The form protects new entries; bulk verification cleans the database you already have.

How do you add verified email validation to a React signup form, step by step?

Follow these steps in order. A developer who already runs a Next.js app can finish the setup in an afternoon. For the signup-specific design choices, see how to add real-time email verification to signup forms.

  1. Create an account. Sign up for a free account to test the workflow. Free works for testing, but API access requires Pro.
  2. Get an API key. Open the API key page and create a key for this project.
  3. Store the key on the server. Add UV_API_KEY to .env.local. Never prefix it with NEXT_PUBLIC_, because that exposes it to the browser.
  4. Create the route. Add app/api/verify-email/route.js using the code above. Replace the placeholder endpoint, auth header and mapToStatus function with the values from the API documentation.
  5. Wire the form. Add the schema or pattern rules, then the checkMailbox function, with mode: 'onBlur'.
  6. Spot-check addresses. Use the free email checker to test one known-good address, one known-bad address and one catch-all address before you rely on the route.
  7. Add a confirmation email. Send a link to every new address, and activate the account only after the click. The click is the strongest proof of ownership, and the log supports your compliance and hygiene records.
  8. Log the outcomes. Record the status, timestamp and form source for each check. That lets you see how often Invalid results appear, and whether a form change moves the rate.

Bottom line: Key on the server, check on blur, confirm by email, and log every result.

Worked example: what does a signup form cost at 20,000 attempts a month?

These figures are illustrative, not measured. The assumptions are stated so you can swap in your own. The plan limits are real: Pro includes 100,000 API emails and 25,000 deep verifications a month, at $29 per month or $25 billed annually.

Assume 20,000 signup attempts a month. Assume each attempt is one completed address, and that 10% of attempts reuse an address you have already checked.

The per-keystroke design would need more than three times the included API volume, and the blur-plus-cache design fits comfortably within the same plan. The design decision matters more than the plan price.

Bottom line: Blur-triggered checks with caching cut request volume by about 94% in this scenario, on the same $29 plan.

What are the common mistakes with email validation in React Hook Form?

Most failures come from putting the right check in the wrong place, not from the check itself.

Bottom line: Most of these mistakes come from a check running in the wrong layer or at the wrong moment.

How we compared (and limitations)

This guide is based on public documentation: the React Hook Form and Zod docs, the RFCs, the WHATWG HTML Standard, and Unlimited Verifier's published plan details. We have not benchmarked these libraries or load-tested any verification service. Library behaviour can change between versions, so confirm details in the current docs.

Unlimited Verifier's 99.5% accuracy figure for deep verification is the company's stated figure, not an independent benchmark. The worked-example percentages and request counts are illustrative. The code samples use placeholder endpoints, headers and mapping functions, so replace them with the values from the API documentation before deploying. If you want to see how the open-source checks are structured, the engine is published at github.com/unlimitedverifier/free-email-verifier.

Three-layer validation flow

  1. Browser (instant): Zod schema with z.string().trim().max(254).email(). Runs on every change or blur. No network call.
  2. Server (on blur, cached): POST the address to your own route, such as /api/check-email. The route calls the verification provider with a server-side key and returns valid, invalid or risky.
  3. Policy (in the route): Block invalid. Flag risky (catch-all, disposable, role-based) for review.
  4. Ownership (after submit): Send a confirmation link. Activate the account only after the click.
Result Action
Format fails Show inline error, no network call
Invalid mailbox Block submission
Risky Allow with review flag or policy rule
Valid Proceed to confirmation email

Frequently asked questions

Should I use a regex or Zod for email validation in React Hook Form?

Use Zod with zodResolver for most forms, because it keeps the schema readable, typed and reusable on the server. A simple pattern rule is fine for a small form. Either way, keep the rule loose enough to accept valid addresses like jane+news@example.com.

Why does my React Hook Form email validation run on submit too?

handleSubmit runs all registered rules again before submitting, including async validate functions. If your mailbox check is slow or costly, cache the result per address and trigger it on blur so submission does not repeat the network call.

Can I call an email verification API directly from React?

You should not. Verification APIs require a secret key, and a client call exposes it in the JavaScript bundle. Call a route on your own server, which holds the key and returns only a simple valid, invalid or risky result to the form.

Does React Hook Form have a built-in email type validator?

No. React Hook Form does not ship an email validator. You supply the rule using pattern, validate, or a schema resolver such as Zod or Yup. The HTML type="email" attribute adds some browser checks, but it is loose and should not be your only rule.

How do I show a custom error message for an invalid email?

Set the message in the rule object, for example pattern: { value: regex, message: 'Enter a valid email' }. Read the error through formState.errors.email and render it beneath the input. With a Zod schema, put the message in the z.string().email() call.

Should I reject catch-all email domains?

Usually not automatically. A catch-all domain accepts mail for any address, so a lookup cannot confirm the specific mailbox. Treat it as a risk signal, let the user proceed, and rely on a confirmation email to verify ownership.

Does email validation in React confirm the person owns the address?

No. Format checks and mailbox lookups cannot prove control of an inbox. Send a confirmation link and require a click before activating the account.

How long can an email address be in React Hook Form validation?

RFC 5321 limits the local part to 64 characters, and many libraries cap the full address at 254 characters. Apply these as a maximum length rule in your schema, and treat them as practical limits rather than strict spec requirements.

Should I trim whitespace from the email before validating?

Yes. Trim and lowercase the value in the Zod schema or a transform before validation. Pasted addresses often include leading or trailing spaces, which would otherwise fail a format check that the user cannot see.

Cut Bounces and Protect Your Sender Reputation With Unlimited Email Verification

Every invalid address you send to hurts your sender reputation and your inbox placement. Verifying your list before each send means fewer bounces, healthier deliverability, and a predictable cost. With Unlimited Verifier, standard verification is unlimited on every plan, with no per-email fees.

Unlimited Verifier checks syntax, domain, MX records and the SMTP mailbox. It also detects catch-all domains and flags disposable and role-based addresses. Export a CSV from your email platform or CRM, upload and verify the list, then re-import the clean results. You can also automate checks with the email verification API.

Free Pro
Price $0 $29/month ($25/month billed annually)
Lists 25 a month, up to 150 emails each Unlimited, up to 25,000 emails each
Deep verifications 750 a month 25,000 a month
API access No Yes (100,000 emails a month)
Result retention 24 hours 30 days

Why teams choose Unlimited Verifier

Unlimited Verifier states 99.5% accuracy for deep verification.

Create a free account and verify your next list before you hit send.

Want to test a single address first? Try the free email checker.