Run a contact form on Vercel without a serverless function
A contact form on a Vercel site doesn't need a serverless function. The browser posts straight to FormThunder, which stores the submission and emails you, so you use no function invocations and hold no secrets. Set the access key as an environment variable with your framework's public prefix. The one Vercel-specific catch is preview URLs if you restrict domains.
Updated
The Vercel code
vercel env add NEXT_PUBLIC_FORMTHUNDER_KEY production previewexport async function POST(request: Request) {
const fields = await request.json();
const response = await fetch("https://formthunder.com/api/v1/submissions", {
method: "POST",
headers: {
Authorization: "Bearer " + process.env.FORMTHUNDER_API_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({ form_id: process.env.FORMTHUNDER_FORM_ID, fields }),
});
return Response.json(await response.json(), { status: response.status });
}Replace YOUR_ACCESS_KEY with your free key. It's public by design, so it's safe in client code.
Notes for Vercel
- Vercel preview deployments use their own
*.vercel.apphosts. Pro's domain restriction matches subdomains, soallowed_domains: ["yoursite.com"]won't cover them. Addvercel.apponly if you're happy with any Vercel site being able to post. - Use a separate form for previews by giving the preview environment its own key. Real leads and test noise then stay apart.
- Public env vars are inlined at build time, so redeploy after changing one.
- The server route above uses the Submissions API, which needs Pro and a secret API key. Most sites never need it.
Or have your AI add it
Connect the MCP server, then ask. The agent creates the form and writes the code for you, and it can send a real test when it's done.
Add a FormThunder contact form to this Vercel site that emails hello@example.com. Send a test when you're done.Questions
Do I need a Vercel Function for a contact form?
No. Your framework's form component can post from the browser. A function only makes sense if you must add server-side logic first.
Does this affect my Vercel usage?
Browser posts go to FormThunder and not to Vercel, so they use no function invocations.
Get your Vercel form sending
The free plan covers 250 submissions a month, with MCP, the CLI and the brand kit included.