Frameworks and SDKs

Astro email validation integration

A package for Astro servers that checks the email address of a form post before your code runs: in an endpoint, in middleware for the paths you list, or inside an action. It refuses addresses that cannot receive email and throwaway inboxes, and lets a real person through when the API cannot answer in time.

Read the full setup guideGet an API key

  • Setup guide
  • An npm package file for your Astro project

Middleware for your form pathssrc/middleware.ts

TypeScript
import { emailValidationMiddleware } from '@email-validation/astro';

export const onRequest = emailValidationMiddleware({ paths: ['/api/signup'] });

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
Astro developers with sign-up, contact or newsletter forms posted to a server route, who want the addresses that will bounce refused before an account or a subscriber is created.
You need
Astro 7 with an adapter (the route rendered on demand), the package file from the guide, and an API key made for it, with a daily credit cap, set on your server as EV_API_KEY.
Costs
1 credit = 1 validated address, as with any API request. Free: unknown results, API errors, malformed addresses, test addresses on sandbox.email-validation.org, addresses on reserved domains such as example.com and, in a bulk list, repeats of an address (charged once).
Full guide
Read the full setup guide

Typical uses.

  • An endpoint

    withEmailValidation wraps an endpoint’s handler. The check reads a clone of the request, so the handler reads the body as usual, and a refused address never reaches it.

  • Middleware for several paths

    emailValidationMiddleware checks a POST to each path you list before the route runs, and hands the outcome to the route in context.locals.emailCheck (Astro.locals.emailCheck in an .astro page).

  • In an action

    createEmailCheck gives you the check on its own, for an action’s handler or a page that handles its own form post.

Set it up. 5 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 package

    The package is not on npm yet: download the file from the guide into your project, and commit it if you want it in your dependencies.

  2. Install it

    Run npm install with the file’s path. The package has no dependencies of its own.

  3. Set your key

    Create an API key with Validate addresses and a daily credit cap, and set it on your server as EV_API_KEY, never in code or a client script.

  4. Check a route

    Wrap an endpoint in withEmailValidation(), or list your form paths in emailValidationMiddleware().

  5. Try it

    Post disposable@sandbox.email-validation.org, which is refused, and accepted@sandbox.email-validation.org, which passes. Test addresses cost nothing. On a form that mails the address, try only the one that is refused.

Good to know.

  • invalid and disposable are refused by default with HTTP 422; stopOn changes the list. catch_all and unknown pass unless you add them.

  • When the check cannot finish (a timeout, a network error, our error, no key, a 429 pause), the request goes on as if the address were fine. Set failOpen: false to refuse with 503 instead.

  • The address and the key never reach a log, an error or the outcome your code gets.

  • For EU data residency, set region: 'eu' to send checks to https://api-eu.email-validation.org: the same key works on both.

Connect Astro.

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