Contact form for Bolt
Bolt.new generates and runs full-stack JavaScript apps in the browser (StackBlitz WebContainers), usually React + Vite or Next.js. A contact form only needs somewhere to POST: paste the Pasteform prompt and Bolt wires it up, without adding a server or database.
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 AI prompt from the form page.
- Paste the prompt into the Bolt chat. Bolt edits the contact component to
fetchyour endpoint with JSON. - Test in Bolt's preview. The preview runs on a StackBlitz/WebContainer domain, so keep the allow-list empty while testing, or add the preview hostname.
- Deploy from Bolt, then add the deployed hostname (shown after deploying) and your custom domain to Allowed domains.
Prompt to paste into Bolt
Make the contact form submit to https://forms.prizenlabs.com/f/YOUR_FORM_ID.
Use fetch with method POST, headers {"Content-Type":"application/json","Accept":"application/json"},
and a JSON body of the form fields (name, email, message, plus a hidden empty "_gotcha" honeypot).
Show "Thanks! We'll be in touch soon." when the JSON response has success: true, otherwise show its "message".
Do not add a server, API route, database or environment variable for this.React component (if you prefer to paste code)
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 hostname Bolt deploys to and your custom domain. Preview hostnames change, so test previews with an empty allow-list.
Common pitfalls
- If the request fails in the preview with a 403, your allow-list doesn't include the preview hostname.
- Bolt may suggest a backend route that forwards to the endpoint. Not needed, and a server-side request has no browser Origin, so it fails once you set an allow-list.
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 · v0 · Framer · Webflow · Astro · Next.js · Hugo · Jekyll · GitHub Pages · Netlify · Vercel · WordPress (static export) · Carrd · plain HTML