Replace a hand-rolled contact API route
A contact form built from scratch usually grows an API route, an email service, an API key in environment variables, and no spam protection. It is easy to write and tedious to keep working. If the route only receives a form and sends an email, you can delete it and post the form to an endpoint instead.
- 1
Create a free FormTango account and add a form. Copy its endpoint, which looks like https://formtango.com/f/YOUR_FORM_ID.
- 2
Point the form at the endpoint: change the fetch URL, or set the form's action.
- 3
Delete the API route, the email library and its API key.
- 4
Submit the form once. The submission appears in your FormTango inbox and you get an email.
typescript
// Before: your own route, an email service and a secret key
// app/api/contact/route.ts
// const resend = new Resend(process.env.RESEND_API_KEY);
// await resend.emails.send({ from, to, subject, text });
// After: no route, no key
const response = await fetch('https://formtango.com/f/YOUR_FORM_ID', {
method: 'POST',
headers: { Accept: 'application/json' },
body: new FormData(form),
});
const result = await response.json(); // { ok: true }Good to know
- What you stop maintaining: input validation, rate limiting, spam filtering, email deliverability, and a place to store submissions when an email is missed.
- What you keep: your own form markup and design. Only the destination changes.
- There is no secret to leak. The endpoint only accepts submissions, so it is safe in front-end code and in a public repository.
- Need the data in your own system too? Add a webhook and each submission is posted to your server as signed JSON.
What you get
- Every submission saved in an inbox you can search and export.
- An email for each one, with the visitor's address as the reply-to.
- Spam filtering without making visitors solve a puzzle.
- Problems? See troubleshooting.
Related guides
HTML form to emailContact form without a backendSubmit a form without redirectingHTML file upload formStop contact form spam
Last reviewed November 19, 2026.