# Astro Email Validation Integration

URL: https://email-validation.org/integrations/astro/
Updated: 2026-12-05

> Documentation index: https://email-validation.org/llms.txt

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 guide](https://email-validation.org/docs/guides/astro/) [Get an API key](https://email-validation.org/signin/)

- Status: Setup guide
- An npm package file for your Astro project

**Middleware for your form paths** src/middleware.ts

TypeScript

```text
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](https://email-validation.org/app/api-keys/) made for it, with a [daily credit cap](https://email-validation.org/docs/authentication/#limits), 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](https://email-validation.org/docs/guides/astro/)

## 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](https://email-validation.org/docs/guides/astro/), which stays the reference when a step does not match what you see.

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](https://email-validation.org/docs/eu-data-residency/), set `region: 'eu'` to send checks to `https://api-eu.email-validation.org`: the same key works on both.

## Related

- [The full Astro setup guide](https://email-validation.org/docs/guides/astro/)
- [Every setting and its default](https://email-validation.org/docs/guides/astro/#settings)
- [Validating sign-up forms: what to block and what to accept](https://email-validation.org/docs/guides/signup-form-validation/)
- [The JavaScript client library, for other calls such as bulk lists](https://email-validation.org/docs/sdks/javascript/)
- [BigQuery email validation integration](https://email-validation.org/integrations/bigquery/)
- [Command-line tool email validation integration](https://email-validation.org/integrations/cli/)
- [ClickHouse email validation integration](https://email-validation.org/integrations/clickhouse/)
- [Coolify email validation integration](https://email-validation.org/integrations/coolify/)
- [All integrations](https://email-validation.org/integrations/)
