A contact form for a site on Vercel
Point the form at FormHaven and every message reaches your inbox, whether the site is plain HTML, Astro or Next.js on Vercel. Nothing runs in a Vercel function, and messages are stored in the EU.
14 days free, no card. Paste the address where the code says YOUR_FORM_ID.
<form action="https://formhaven.net/f/YOUR_FORM_ID" method="POST">
<input type="email" name="email" required>
<textarea name="message" required></textarea>
<input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off">
<input type="hidden" name="_next" value="/thanks">
<button type="submit">Send</button>
</form>
Set it up
-
1
Know what Vercel gives you
Vercel's own guides send a static site's form to an outside backend (their example uses Formspree), and a Next.js site to a Server Action that you write and run. FormHaven is the outside backend.
-
2
Create a form in FormHaven
Sign up, press New form and copy its address. It looks like https://formhaven.net/f/YOUR_FORM_ID.
-
3
Paste the form
Put your address in the action and deploy as usual. No environment variable, no function, nothing in vercel.json.
-
4
Send a test
Fill in the form on your deployment and check your inbox. Or press Send a test submission in FormHaven.
Next.js: keep the visitor on the page
A client component that sends the form with fetch and shows the answer under the button. No Server Action, no API route, and no email key on your server.
"use client";
import { useState, type FormEvent } from "react";
export function ContactForm() {
const [status, setStatus] = useState("");
async function send(event: FormEvent<HTMLFormElement>) {
event.preventDefault();
const form = event.currentTarget;
const response = await fetch(form.action, {
method: "POST",
headers: { Accept: "application/json" },
body: new FormData(form),
});
const { ok, message } = await response.json();
setStatus(ok ? "Thanks, your message is on its way." : message);
if (ok) form.reset();
}
return (
<form action="https://formhaven.net/f/YOUR_FORM_ID" method="POST" onSubmit={send}>
<input type="email" name="email" required />
<textarea name="message" required />
<input type="text" name="_gotcha" style={{ display: "none" }} tabIndex={-1} autoComplete="off" />
<button type="submit">Send</button>
<p role="status">{status}</p>
</form>
);
}
Stop bots that skip the hidden field
Turn on the bot check in the form's settings and add this line once to the page, or to your root layout in Next.js. It also finds forms React draws after the page loads. Visitors see nothing, and it sets no cookies.
<script src="https://formhaven.net/bot-check.js" async></script>
Questions about this setup
- Does it work on preview deployments?
- Yes. Form addresses accept requests from any website. If you limit the form to your own domains in its settings, add the preview domain too, or test on production.
- Why not a Server Action with an email API?
- That works, but you write and run the code, keep an email API key on the server, and still need spam filtering and somewhere to read old messages. Posting to FormHaven gives you all of that with one action attribute.
- Can my client get the messages instead of me?
- Yes. Add up to 5 more addresses to the form. Each one confirms by a link first, and their copy carries no FormHaven branding. You can turn your own copy off.
- Where is the data stored?
- On our servers in the EU, for 1 to 365 days as you choose per form, or not at all: then each message is emailed and its answers deleted. A data processing agreement covers every account.
More to read
Get your form address in a minute
14 days free, no card. Then €1 per form a month, €0.50 from the 11th form.