Docs / Hosting
Contact form on Vercel, no serverless function
A static site on Vercel can take contact form submissions with no function, no API route and no environment variables. The browser posts to Wrenform.
<form action="https://wrenform.com/f/YOUR_FORM_ID" method="POST">
<input type="text" name="name" required>
<input type="email" name="email" required>
<textarea name="message" required></textarea>
<input type="text" name="_honey" style="display:none" tabindex="-1" autocomplete="off">
<button type="submit">Send</button>
</form>
<!-- Optional: a timing check against bots, and data-ajax to submit in place -->
<script src="https://wrenform.com/js/v1/form.js" defer></script>Why no function is needed
The usual way to handle a form on Vercel is an API route or serverless function that receives the post, checks for spam and calls an email service. With Wrenform the visitor's browser posts the form straight to your endpoint, https://wrenform.com/f/YOUR_FORM_ID. We store the submission, filter spam and email you. Your project stays static.
There is nothing to put in Vercel's environment variables either: the form ID is public by design. Allowed origins stop other sites from posting to your form.
Steps
- Create a form and copy its form ID, or let your AI tool create one without an account.
- Put the form on your contact page, with your form ID in the
action. Keep the hidden_honeyfield: it's a honeypot, a field people never see, so only bots fill it in. - Add a thank-you page and set its full address as the form's Redirect to, for example
https://example.com/thanks. See redirects. - Push. Vercel deploys as usual.
- In the form's settings, add your production address under Allowed origins, for example
https://example.com.
Next.js, Astro and other frameworks
Use the component from your framework's guide instead of the plain form. Each one keeps the build static:
- Next.js: a client component, no server action or route handler.
- Astro: a static component, no adapter.
- React, Vue and SvelteKit.
Allowed origins on Vercel
- Your site may answer on both
https://example.comandhttps://www.example.com. Add both, or redirect one to the other in Vercel's domain settings. - Preview deployments get their own
vercel.appaddresses. Leave Allowed origins empty while you test them (an empty list lets any website post to the form), or add each preview address. Add your production address before you go live.
Spam
Filtering is on for every form, with no captcha: the honeypot, a timing check, rate limits and a content score. Spam goes to its own tab and is never emailed. For an extra bot check, add Turnstile with your own keys.
Test it
Open the deployed page, send the form, and you should land on your thank-you page. The submission shows in your dashboard and arrives by email.
Common problems
origin_not_allowed. The address in the browser isn't under Allowed origins: checkwww, and preview addresses. See errors.- You see our thank-you page, not yours. Redirect to is empty, or it isn't an
https://address. - No email arrives. A new recipient must confirm first. See troubleshooting.
Next steps
- My form isn't working: symptom, cause and fix.
- Netlify and Cloudflare Pages: the same form on other hosts.