Zephos Formsby Zephos

Guide · Lovable

Add a working contact form to a Lovable app

Lovable builds a React front end. You can wire the form yourself or paste the prompt below into Lovable's chat and let it do the edit.

  1. Create a free account and a form. Copy its access key.

  2. In Lovable's chat, paste this prompt with your key filled in:

    Make the contact form send its submissions to Zephos Forms.
    On submit, POST JSON to https://forms.zephos.dev/submit with the header
    "Accept: application/json" and the body
    { "access_key": "YOUR_ACCESS_KEY", "name": ..., "email": ..., "message": ... }.
    Add a hidden text input named "_gotcha" that is positioned off-screen
    (a spam trap) and include its value in the body.
    Show "Thanks, we got your message." when the response has success: true,
    and an error message otherwise. Don't add a backend or Supabase table for this.
  3. Or replace the form component yourself:

    import { useState } from "react";
    
    export function ContactForm() {
      const [status, setStatus] = useState("idle");
    
      async function onSubmit(e) {
        e.preventDefault();
        setStatus("sending");
        const data = Object.fromEntries(new FormData(e.currentTarget));
        const res = await fetch("https://forms.zephos.dev/submit", {
          method: "POST",
          headers: { "Content-Type": "application/json", Accept: "application/json" },
          body: JSON.stringify({ access_key: "YOUR_ACCESS_KEY", ...data }),
        });
        setStatus(res.ok ? "sent" : "error");
      }
    
      if (status === "sent") return <p>Thanks, we got your message.</p>;
      return (
        <form onSubmit={onSubmit}>
          <input name="name" placeholder="Name" required />
          <input name="email" type="email" placeholder="Email" required />
          <textarea name="message" placeholder="Message" required />
          <input type="text" name="_gotcha" tabIndex={-1} autoComplete="off"
                 style={{ position: "absolute", left: "-5000px" }} aria-hidden="true" />
          <button disabled={status === "sending"}>Send</button>
          {status === "error" && <p>Something went wrong. Try again.</p>}
        </form>
      );
    }
  4. Submit the form once from your live site. The submission shows up in your dashboard and in your inbox.

Good to know

Other guides: Plain HTML · Astro