All guides

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

  1. Create a form in Pasteform and copy the AI prompt from the form page.
  2. Paste the prompt into the Bolt chat. Bolt edits the contact component to fetch your endpoint with JSON.
  3. 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.
  4. 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

What you get

Make your Bolt form send

Free form link in about 2 minutes. No credit card.

Get my free form link

Guides for other platforms

Lovable · v0 · Framer · Webflow · Astro · Next.js · Hugo · Jekyll · GitHub Pages · Netlify · Vercel · WordPress (static export) · Carrd · plain HTML