Contact form for Vercel
On Vercel you can write a serverless function to handle a form, but then you also maintain an email integration and its secrets. For a contact form, post from the browser to Pasteform and skip the function.
Get my free form link Replace YOUR_FORM_ID below with your form ID, or copy the snippets from your dashboard where it's already filled in.
Step by step
- Create a form in Pasteform and copy the endpoint.
- Static/Vite sites: paste the HTML snippet. Next.js: use the client component from the Next.js guide.
- Deploy, then add
your-project.vercel.appand your custom domain to Allowed domains.
HTML
<form action="https://forms.prizenlabs.com/f/YOUR_FORM_ID" method="POST"> <label>Name <input type="text" name="name" required></label> <label>Email <input type="email" name="email" required></label> <label>Message <textarea name="message" required></textarea></label> <input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off"> <button type="submit">Send</button> </form>
React / Next.js
"use client";
import { useState } from "react";
export default function ContactForm() {
const [state, setState] = useState<"idle" | "sending" | "sent" | "error">("idle");
const [error, setError] = useState("");
async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {
e.preventDefault();
setState("sending");
const form = e.currentTarget;
const res = await fetch("https://forms.prizenlabs.com/f/YOUR_FORM_ID", {
method: "POST",
headers: { "Content-Type": "application/json", Accept: "application/json" },
body: JSON.stringify(Object.fromEntries(new FormData(form))),
});
const data = await res.json().catch(() => ({}));
if (res.ok && data.success) {
form.reset();
setState("sent");
} else {
setError(data.message ?? "Something went wrong");
setState("error");
}
}
if (state === "sent") return <p>Thanks! We'll be in touch soon.</p>;
return (
<form onSubmit={handleSubmit} className="space-y-3">
<input name="name" placeholder="Name" required />
<input name="email" type="email" placeholder="Email" required />
<textarea name="message" placeholder="Message" required />
<input name="_gotcha" className="hidden" tabIndex={-1} autoComplete="off" />
<button type="submit" disabled={state === "sending"}>
{state === "sending" ? "Sending…" : "Send"}
</button>
{state === "error" && <p role="alert">{error}</p>}
</form>
);
}
Allowed domains
Add the production hostname and custom domain. Preview deployments use unique hostnames; add the ones you test on.
Common pitfalls
- If you set a Content-Security-Policy in
vercel.jsonor middleware, allow the Pasteform origin inconnect-src(fetch) andform-action(HTML forms).
What you get
- Email notifications with Reply-To set to your visitor, plus optional Slack, Discord, Telegram or webhook alerts.
- Spam protection: honeypot, rate limits, domain allow-list, optional Cloudflare Turnstile.
- Submissions stored for as long as you choose (or not at all), with CSV export and one-click deletion.
- Free for 250 submissions a month; Pro is $9/month for 5,000.
Guides for other platforms
Lovable · Bolt · v0 · Framer · Webflow · Astro · Next.js · Hugo · Jekyll · GitHub Pages · Netlify · WordPress (static export) · Carrd · plain HTML