Sign-up and auth

Better Auth integration

A Better Auth server plugin checks each new user’s address with our API before Better Auth creates the user and, when the result is one you stop, the sign-up is refused with an error your client can show. Magic link and email OTP sign-ups are checked before any mail is sent.

Read the full setup guideGet an API key

  • Setup guide
  • One TypeScript plugin file, no database tables

Server variablenever in browser code

Environment
EV_API_KEY   your API key

At a glance.

Status
Setup guide. Not listed on a marketplace yet: you set it up yourself in a few steps, below and in the full guide.
For
Apps built on Better Auth that want accounts made with an undeliverable or throwaway address kept out, whether people sign up with a password, a magic link, a one-time code or an OAuth provider.
You need
A Better Auth server, and an API key made for it, with a daily credit cap, kept in a server variable. The plugin goes into your server config only, never into the auth client.
Costs
1 credit = 1 validated address, as with any API request. Free: unknown results, API errors, malformed addresses and test addresses on sandbox.email-validation.org.
Full guide
Read the full setup guide

Typical uses.

  • Refuse it with a clear error

    An email and password sign-up with a stopped address gets an error with the code EMAIL_ADDRESS_NOT_ACCEPTED and your message, and no user row is written.

  • Send no mail to a bad address

    Magic link and email OTP sign-ups are checked before the link or code goes out, so a stopped address never gets one and no user follows.

  • Leave returning users alone

    Only a new user reaches the check. Someone signing in again, or linking a new provider to an account they have, is never checked and never charged.

Set it up. 4 steps.

The short version of the full setup guide, which stays the reference when a step does not match what you see.

Read the full setup guide

  1. Download the file

    It is not on a registry yet: download email-validation-better-auth.ts from the guide and put it next to your Better Auth config.

  2. Add the plugin

    Add emailValidation({ apiKey: process.env.EV_API_KEY }) to the plugins of your server betterAuth() config. There is no migration to run.

  3. Show the error

    On the client, show error.message when error.code is EMAIL_ADDRESS_NOT_ACCEPTED. For OAuth, read error from your error callback page.

  4. Test it

    Sign up with email and password as disposable@sandbox.email-validation.org: it is refused, for free. Test addresses receive no mail, so do not use them for magic links or codes that would really be sent.

Good to know.

  • A user who changes their address later is not checked, and neither is anything that writes user rows to the database without going through Better Auth.

  • No key, a timeout, no credits or any other error lets the sign-up through. A check is never retried.

  • A magic link or code checked when it was sent is not checked again when it is used on the same server; on serverless hosts one sign-up can cost up to 2 credits.

  • Nothing is logged, and the address goes only to our US host, or with region: 'eu' to our EU host.

Connect Better Auth
in a few minutes.

Test it on our sandbox addresses for free, then on your own contacts.

Create your accountRead the full setup guide

Updated · Maintained by: Email Validation LLC