Falkenstein, Germany · Hetzner Online GmbH
FormHaven

A React contact form that emails you every message

Drop one component into a Vite app, or any React project, and every message is spam filtered, stored in Germany and emailed to you. Your bundle carries only a public form address, and the browser posts straight to us.

14 days free, no card. Paste the address where the code says YOUR_FORM_ID.

src/ContactForm.tsx
import { useState, type FormEvent } from "react";

type Problem = { field?: string; message: string };

export function ContactForm() {
  const [sending, setSending] = useState(false);
  const [sent, setSent] = useState(false);
  const [problems, setProblems] = useState<Problem[]>([]);

  async function send(event: FormEvent<HTMLFormElement>) {
    event.preventDefault();
    const form = event.currentTarget;
    setSending(true);
    const response = await fetch(form.action, {
      method: "POST",
      headers: { Accept: "application/json" },
      body: new FormData(form),
    });
    const result = await response.json();
    setSending(false);
    setSent(result.ok);
    setProblems(result.ok ? [] : result.errors);
    if (result.ok) form.reset();
  }

  const problem = (field: string) => problems.find((p) => p.field === field)?.message;

  return (
    <form action="https://formhaven.net/f/YOUR_FORM_ID" method="POST" onSubmit={send}>
      <label>Your email <input type="email" name="email" required /></label>
      {problem("email") && <p>{problem("email")}</p>}
      <label>Message <textarea name="message" required /></label>
      <input type="text" name="_gotcha" style={{ display: "none" }} tabIndex={-1} autoComplete="off" />
      <button type="submit" disabled={sending}>{sending ? "Sending..." : "Send"}</button>
      <p role="status">{sent ? "Thanks, your message is on its way." : problems.find((p) => !p.field)?.message}</p>
    </form>
  );
}

Set it up

  1. 1

    Create a form in FormHaven

    Sign up, press New form and copy its address. It looks like https://formhaven.net/f/YOUR_FORM_ID.

  2. 2

    Add the component

    Save the code above as src/ContactForm.tsx, paste your address into the action, and render <ContactForm /> where the form belongs.

  3. 3

    Read the answer

    With Accept: application/json the reply is {"ok": true}, or {"ok": false, "errors": [...]} where each error has a code, a message and, when one input caused it, the field name.

  4. 4

    Send a test

    Run npm run dev, fill in the form and check your inbox. Localhost is always allowed, so you can test before you deploy.

With React 19 actions

React 19 lets a form take a function as its action and calls it with the form data. It is shorter, with two costs. React clears the fields after every send, errors included. And the form has no address of its own, so the bot check cannot find it and the form cannot post without JavaScript. Leave the bot check off.

src/ContactForm.tsx
import { useActionState } from "react";

async function send(_previous: unknown, data: FormData) {
  const response = await fetch("https://formhaven.net/f/YOUR_FORM_ID", {
    method: "POST",
    headers: { Accept: "application/json" },
    body: data,
  });
  return response.json();
}

export function ContactForm() {
  const [result, action, pending] = useActionState(send, null);

  return (
    <form action={action}>
      <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" disabled={pending}>Send</button>
      <p role="status">{result?.ok ? "Thanks, your message is on its way." : result?.errors?.[0]?.message}</p>
    </form>
  );
}

A test form and a live form

Keep the address in a Vite environment variable and point development at a second form, so your tests never land in the live inbox. The address is public either way: it can receive messages, never read them.

.env.development
VITE_FORM_URL=https://formhaven.net/f/YOUR_TEST_FORM_ID

# in ContactForm.tsx:
# <form action={import.meta.env.VITE_FORM_URL} method="POST" onSubmit={send}>

Stop bots that skip the hidden field

Turn on the bot check in the form's settings and add this line once to index.html. It finds forms React draws after the page loads. Visitors see nothing, and it sets no cookies.

index.html
<script src="https://formhaven.net/bot-check.js" async></script>

Questions about this setup

Why not EmailJS or an email API?
An email API needs a key that must stay off the page, so you end up running a server anyway. FormHaven gives you one public address, with spam filtering and a place to read old messages.
Can an agent set this up for me?
Yes. Ask Claude Code or Cursor to add a FormHaven contact form. Through our MCP server it can fetch a ready React component for your form with get_form_code.
Does it still work without JavaScript?
Yes, in the main version. The form has a real action and method, so the browser posts it the normal way and the visitor sees our thank-you page, or yours if you set one on the form.
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 server at Hetzner in Falkenstein, Germany, for 1 to 365 days as you choose per form, or not at all. A data processing agreement covers every account.

More to read

Next.js contact formThe same component in a Next.js app Astro contact formA Contact.astro component for a static Astro site HTML form to emailOne line in the action, every message in your inbox Static site contact formOne form for Astro, Hugo, Eleventy, Jekyll or plain HTML Hugo contact formA partial and a shortcode for a static Hugo site Lovable contact formOne prompt for a site built with Lovable GDPR compliant contact formEU storage, a DPA and retention you set Kontaktformular nach DSGVOAuf Deutsch: gespeichert in Deutschland, mit AVV JavaScript contact formA fetch script that keeps the visitor on the page Vercel contact formFor plain HTML, Astro or Next.js hosted on Vercel FormSubmit not workingThe usual causes of a silent FormSubmit form Web3Forms not workingThe usual causes of a silent Web3Forms form Eleventy contact formAn include for a static Eleventy (11ty) site Formspree not workingThe usual causes of a silent Formspree form Export from FormspreeEvery Formspree submission, as a file Export from FormsparkEvery Formspark submission, as a file EmailJS not workingThe usual causes of a silent EmailJS form Form backend for AI agentsThe start request, every REST route and MCP tool Claude Code contact formOne prompt, then press Activate Cursor contact formThe prompt and the .cursor/mcp.json entry Contact form privacy policyThe paragraph to copy, in 8 languages GitHub Pages contact formFor user, organisation and project sites on github.io Cloudflare Pages contact formFor sites on pages.dev or your own domain Netlify contact formFor sites on netlify.app or your own domain Send form submissions to multiple emailsUp to 5 confirmed addresses per form, plus yours SvelteKit contact formOne Svelte 5 component, any adapter Nuxt contact formOne Vue component for Nuxt 4 and 3 Gatsby contact formOne component for a Gatsby 5 site HTML form webhookSigned JSON to your endpoint for every message Jekyll contact formAn include for Jekyll, on GitHub Pages or any host Angular contact formA standalone component that posts with HttpClient Contact form spamWhy forms get spam, and the layers that stop it Contact form honeypotThe hidden field that catches bots, and how to hide it Contact form without PHPFor hosts with no PHP, or mail() that lands in spam HTML form mailtoWhy action="mailto:" fails on webmail visitors, and the one-line fix Contact form templateThe same form in plain HTML Pricing€1 per form a month, €0.50 from the 11th

Get your form address in a minute

14 days free, no card. Then €1 per form a month, €0.50 from the 11th form.

Start your 14-day trial