Alpine.js
Alpine.js contact form that posts without a page reload
Alpine.js is enough to post a contact form without a page reload. The component below sends JSON to Heartdove with fetch, keeps a submit phase for the button, and includes an idempotency key so a retry is safe.
Updated 20 October 2026
Add the form to Alpine.js
Paste the form and the script into any page that loads Alpine. A plain HTML form with the action set to the endpoint also works if you would rather not use fetch.
<form x-data="contactForm()" @submit.prevent="send($el)">
<label>Email <input type="email" name="email" required /></label>
<label>Message <textarea name="message" required></textarea></label>
<input type="checkbox" name="botcheck" tabindex="-1" autocomplete="off" style="display:none" />
<button :disabled="phase === 'submitting'" x-text="phase === 'sent' ? 'Sent' : 'Send message'"></button>
</form>
<script>
function contactForm() {
return {
phase: 'idle',
async send(form) {
this.phase = 'submitting';
const response = await fetch('https://submit.heartdove.com/v1/submit', {
method: 'POST',
headers: { Accept: 'application/json', 'Idempotency-Key': crypto.randomUUID() },
// A regular form post: the spam trap and checkbox groups are handled by the endpoint.
body: (() => { const data = new URLSearchParams(new FormData(form)); data.set('access_key', 'YOUR_ACCESS_KEY'); return data; })(),
});
this.phase = response.ok ? 'sent' : 'error';
},
};
}
</script>A 202 response means the message is stored. Delivery of the email alert is shown on the message in your inbox, not in the response.
Register your website address
Heartdove accepts a submission only from the exact website addresses registered on the form, so a copied key cannot be fired from somewhere else. Register every address the form is published on; each form takes up to 10, and registering a www address covers the bare domain too. For a Alpine.js site that usually means:
https://www.yourdomain.com
Testing locally? Register your local address, such as http://localhost:3000, as well.
What happens after submit
The message is saved to your inbox before any email is sent, so a failed alert never loses the enquiry. The alert is then tracked step by step and shown on the message:
- CapturedSaved and searchable
- Accepted by providerHanded to the email provider
- DeliveredThe recipient’s mail server accepted it
- BouncedShown with the reason; the address is paused
Over your monthly allowance, submissions are held, visibly, and released automatically. Nothing is billed as overage, and each plan’s hold capacity is on the pricing page. The Free plan includes 500 submissions a month with an instant alert for each.
Spam, without a CAPTCHA
Every form gets the exact origin check, a per-visitor rate limit, the hidden trap field and spam scoring with quarantine. Cloudflare Turnstile can be turned on per form for a human check, and is never required. Read how the layers work.
Questions
Is it safe to put the access key in my page?
Yes. The key is public and only identifies the form; it does not grant access to anything. Submissions are accepted only from the website addresses you register, each visitor is rate limited, and every message is scored for spam before it is stored.
Do I need a CAPTCHA?
No. Every form gets an exact origin check, a per-visitor rate limit, a hidden trap field and spam scoring with quarantine. Cloudflare Turnstile is optional for forms that want a human check.
What happens if I go over the free limit?
Submissions above your monthly allowance are held, visibly, for at least seven days and released automatically when your allowance resets. Each plan’s hold capacity is on the pricing page, and there is no overage charge.
Never lose another enquiry.
Connect your first form in a few minutes. Your existing design stays exactly as it is.