Guides Bolt
Make a Bolt contact form actually send
Bolt is quick to build a good-looking contact form, but the submit handler is often a placeholder: it shows a success message and sends nothing. Give Bolt the prompt below and the form posts to sendm8 instead, so every message reaches your inbox.
What Bolt builds
Unless you ask for something else, Bolt builds websites with React, Vite and Tailwind CSS. The preview runs in your browser on StackBlitz WebContainers, and publishing puts the site on a free .bolt.host address, or on Netlify if you connect it. The fix below is the same wherever it’s hosted.
The prompt
Change you@example.com to your own address and paste this into the Bolt chat. With a form from the dashboard, use its URL instead.
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.
- Don’t add a database table, server function, Resend or any secret for this. The form posts straight from the browser.
- Keep the existing design, fields and copy.Look for a fake handler before and after: a setTimeout that pretends to send, or a console.log of the values. The prompt asks Bolt to replace it, but it’s worth checking it’s gone.
What the code should look like
Bolt keeps components in src/components. Without the Tailwind classes, the form should look like this:
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.
Confirm your address, then publish
- Send yourself a test 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. - Publish. The form works on the
.bolt.hostaddress, on Netlify and on a custom domain without any change. - Notifications come from
notify@sendm8.com. Hit reply and you’re writing to the visitor.
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 .bolt.host address, Netlify 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.
Should the endpoint go in .env?
It can, but it doesn’t have to. Bolt’s docs point out that anything your browser code reads from .env ends up in the published site, which is fine here because the endpoint isn’t a secret. If you’d like it in one place, ask for VITE_CONTACT_ENDPOINT in .env and import.meta.env.VITE_CONTACT_ENDPOINT in the component. Don’t put it in Bolt’s Secrets: those only reach server functions, and this form has none.
Spam and limits
The honeypot, rate limits (10 a minute per visitor), spam scoring and an AI check run on every submission. Flagged messages go to a spam folder instead of 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
- Why does my Bolt contact form say “sent” when nothing arrives?
- The generated submit handler is often a placeholder that shows a success state without sending anything. Replace it with a fetch to a form backend such as sendm8, using the prompt on this page.
- Do I need Bolt Cloud or Supabase for a contact form?
- No. Those are for your app’s own data. The form posts from the visitor’s browser to sendm8, which stores the message and emails you.
- Does it work if I publish to Netlify instead of Bolt hosting?
- Yes. Nothing runs on the host, so the same form works on .bolt.host, Netlify or anywhere else you deploy the build.