Get an endpoint Sign inGo to dashboard New form

Guides v0

Add a working contact form to a v0 app

v0 builds a tidy contact form, then either leaves it wired to nothing or reaches for a Server Action, Resend and an API key. For a contact form you can skip all three. Give v0 the prompt below and the form posts straight to sendm8, which emails each message to you.

What v0 builds

v0 writes Next.js apps in React and TypeScript, styled with Tailwind CSS and shadcn/ui. The preview runs on a Vercel Sandbox, and publishing deploys to Vercel with a vercel.app address or your own domain. A client component that calls fetch works the same in all of them.

The prompt

Change you@example.com to your own address and paste this into the v0 chat. If you’ve made a form in the dashboard, use its URL instead.

prompt.txt
Make the contact form send messages to my inbox using sendm8, a free form backend.
Docs: https://sendm8.com/llms.txt

- Endpoint: https://sendm8.com/f/you@example.com
  It needs no API key and no account. It isn't a secret, so don't store it as one.
- On submit, call preventDefault, then POST new FormData(form) to the endpoint with
  fetch and the header "Accept: application/json". Don't set Content-Type.
- Every input needs a name attribute: name, email, message. Keep the visitor's
  email field named "email" so my replies go to them.
- Add a hidden honeypot field to the form:
  <input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off">
- The response is JSON. If ok is true, replace the form with "Thanks! Your message
  is on its way." Otherwise show error.message from the response above the button.
  If fetch itself throws, show a short "Couldn't send, please try again" message.
- Disable the button while sending.
- Make it a client component ("use client"). Don’t add a Server Action, API route, Resend or environment variable for this.
- Keep the existing design, fields and copy.

What the code should look like

v0 usually builds the form from shadcn/ui’s Input, Textarea and Button. Under those, it should come down to this:

components/contact-form.tsx
"use client";

import { useState, type FormEvent } from "react";

const ENDPOINT = "https://sendm8.com/f/you@example.com";

export function ContactForm() {
  const [status, setStatus] = useState<"idle" | "sending" | "sent">("idle");
  const [error, setError] = useState("");

  async function onSubmit(event: FormEvent<HTMLFormElement>) {
    event.preventDefault();
    setStatus("sending");
    setError("");
    try {
      const res = await fetch(ENDPOINT, {
        method: "POST",
        body: new FormData(event.currentTarget),
        headers: { Accept: "application/json" },
      });
      const result = await res.json();
      if (result.ok) {
        setStatus("sent");
        return;
      }
      setError(result.error.message);
    } catch {
      setError("Couldn't send, please try again.");
    }
    setStatus("idle");
  }

  if (status === "sent") return <p>Thanks! Your message is on its way.</p>;

  return (
    <form onSubmit={onSubmit}>
      <label>Name <input name="name" required /></label>
      <label>Email <input name="email" type="email" required /></label>
      <label>Message <textarea name="message" required /></label>
      <input type="text" name="_gotcha" style={{ display: "none" }} tabIndex={-1} autoComplete="off" />
      {error && <p role="alert">{error}</p>}
      <button disabled={status === "sending"}>{status === "sending" ? "Sending…" : "Send"}</button>
    </form>
  );
}

Check three things: the URL in fetch is your endpoint, the Accept: application/json header is there, and every field has a name. Browsers only send named fields, so a missing name is the usual reason a field never arrives. If the AI kept a form library such as react-hook-form, that’s fine too: it can send the values as JSON with Content-Type: application/json, which sendm8 also accepts.

Rather keep it a Server Component with no JavaScript? A plain <form action="…" method="POST"> works on the published site, as in the Next.js guide. It won’t show sendm8’s thank-you page inside the v0 preview, though (see below).

Confirm your address, then publish

  1. Send a test message from the preview. The first time anyone submits, sendm8 stores the message and emails you@example.com (well, your address) one confirmation link. Click it and that message, plus anything that arrived meanwhile, is delivered. After that, submissions just arrive.
  2. Publish. The form works on the vercel.app address and any custom domain with no change.
  3. Each message arrives with the visitor’s address as Reply-To, so replying goes straight to them.

Preview, published site and allowed domains

A plain HTML post would also work on the published site, but the editor shows your app inside a frame, and sendm8’s thank-you page won’t load inside one. That’s why the prompt asks for fetch: the visitor stays on your page in the preview and on the live site alike.

An email endpoint accepts posts from any site, so the preview and the published app both work as they are. If you later switch to a dashboard form and set allowed domains, add every address the app runs on: the preview, the vercel.app address and any custom domain. Anything else gets a 403 with the message “This form doesn’t accept submissions from this website.”

If your app sets a Content-Security-Policy, allow https://sendm8.com in connect-src, or the browser blocks the request before it leaves the page.

Environment variables

None are needed: the endpoint isn’t a secret. If you’d like it in config anyway, it has to be NEXT_PUBLIC_CONTACT_ENDPOINT, because only NEXT_PUBLIC_ variables reach client components. v0 scopes variables to Development, Preview and Production, and its preview only sees Development ones, so add it to all three or the preview form posts to undefined.

Spam and limits

The honeypot catches simple bots. Every submission is also rate-limited, scored for spam and checked by a small AI model, and anything flagged waits in a spam folder rather than your inbox.

A no-account endpoint keeps up to 200 submissions a month and delivers by email. Sign in with the same address and the form moves into your account: 1,000 submissions a month, a dashboard inbox with search and CSV export, and Discord, Slack, Telegram or webhook delivery.

Questions

Do I need a Server Action and Resend for a v0 contact form?
No. They’re one way to send email from Next.js, but they need an API key, a verified domain and code to maintain. Posting the form to sendm8 from the browser replaces all of it.
My v0 form uses react-hook-form and zod. Do I have to remove them?
No. Keep the validation and, in the submit handler, POST the values to sendm8 as JSON with Content-Type and Accept set to application/json. Include an empty _gotcha field.
Will this still work if I export the code or sync it to GitHub?
Yes. It’s ordinary Next.js code with no v0-specific parts, so it works wherever the app is deployed.