Docs

Verify emails in Next.js

Use a route handler in the App Router. The API key stays on your server; the browser only talks to your own endpoint.

Before you start

Create an API key under Settings → API keys and keep it in an environment variable named VALIDREACH_API_KEY on your server. Never ship it in browser or mobile code.

Example

// app/api/verify/route.ts
export async function POST(request: Request) {
  const { email } = await request.json();
  const res = await fetch('https://validreach.dev/api/v1/verify/single', {
    method: 'POST',
    headers: {
      Authorization: `Bearer ${process.env.VALIDREACH_API_KEY}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({ email }),
  });
  const body = await res.json();
  if (!body.success) {
    // Do not block signup if verification is unavailable
    return Response.json({ status: 'unknown' }, { status: 200 });
  }
  return Response.json({
    status: body.data.status,
    is_deliverable: body.data.is_deliverable,
  });
}

Handle the result

Branch on data.status. Treat invalid and disposable as rejections, retry unknown later when retryable is true (unknown is not billed), and decide on catchall, risky and role by your own policy. HTTP 402 means out of credits and 429 means rate limited.