Guides Lovable
Add a working contact form to a Lovable app
Ask Lovable for a contact form today and it saves each message to a database table, with email only once you’ve verified a sender domain on a paid plan. If you’d rather have messages emailed to you straight away, with nothing to set up, one prompt points the form at sendm8 instead.
What Lovable builds
New Lovable apps (since 13 May 2026) use TanStack Start, which renders pages on the server. Older apps use React and Vite. Both are TypeScript and React, and the form code below works the same in either.
Since 3 November 2026, Lovable saves form submissions to a table in your app’s backend, read under More → Database. Its docs say you can name another destination instead, which is what the prompt below does.
When sendm8 is the better fit
Lovable’s table is fine if you’re happy reading messages in Lovable and pay for a plan with email. sendm8 fits better if you want email with no sender domain or paid plan, want messages in Discord, Slack, Telegram or a webhook, might host the code elsewhere later, or would rather not look after a table.
The prompt
Change you@example.com to your own address, then paste this into the Lovable chat. If you already have a form in the dashboard, use its URL instead, such as https://sendm8.com/f/k3x9q2m7ab.
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 save submissions to a table, and don’t add a server function, Edge Function, Resend or any secret for this. The form posts straight from the browser.
- Keep the existing design, fields and copy.The last but one line stops Lovable creating its default table. sendm8 needs no key, and a service without credentials needs no connector or setup.
What the code should look like
Lovable usually puts the form in src/components and styles it with its own UI components. Under the styling, it should come down to 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 a test message 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 unchanged on your
lovable.appaddress or a custom domain. - Reply to any notification and you’re answering the visitor, because their
emailfield becomes the Reply-To.
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 lovable.app address 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.
Spam and limits
The _gotcha honeypot, rate limits, spam scoring and an AI check run on every submission. A no-account endpoint keeps up to 100 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
- Do I need Lovable’s backend, Supabase or Resend for a contact form?
- No. The form posts straight from the visitor’s browser to sendm8, which stores the message and emails you. Lovable’s own table works too, but its email notifications need a verified sender domain on a paid plan.
- Why does the form work on my published site but not in the preview?
- Usually because it does a plain HTML post, and sendm8’s thank-you page can’t load inside the editor’s preview frame. Sending with fetch and Accept: application/json, as the prompt asks, works in both.
- Can I use @sendm8/react instead?
- Yes. Ask Lovable to install @sendm8/react and use its useForm hook with your address or form id. It has the same API as @formspree/react.