React guide

How to add a backend to a React contact form

Use FormData from your existing React component and POST it to Formserve.

No backend API route Honeypot spam trap Works with any host
FS Formserve Team Product guides
React Stack
4 steps setup Walkthrough
Form <form action="…" method="POST"> in the browser
Formserve Validates & filters spam, then stores the submission
Deliver Notifications sent to email, Slack, Sheets, or webhooks
Why a backend at all

The browser can't handle the submission on its own.

An HTML form has to POST somewhere. Formserve is that destination — it receives the submission, screens it for spam, stores it, and sends the notifications. No server to run, no serverless function, no fragile scripts.

Use FormData from your existing React component and POST it to Formserve.

§ 01 · Context Why it still needs a backend.

React forms often already have the UI and validation you need. Formserve lets you keep the component and replace the backend work with a direct POST to an endpoint.

The form POSTs to an endpoint URL, the submission is stored, and notifications are sent according to the endpoint settings. It's a safer, more maintainable replacement for fragile mailto: patterns or one-off scripts that break the first time your host changes.

§ 02 · Why More than just an email alert.

When the backend stores every submission first and notifies second, you get three things a raw SMTP relay can't give you:

Inbox plus notifications

Every submission stays searchable in the Formserve inbox — not just buried in one person's mailbox.

Spam stopped first

Allowed domains, honeypot fields, rate limits, and blocklists run before any notification is sent.

Route later if needed

Start email-only, then add Slack, webhooks, Sheets, or a CRM later without touching the form.

And because the submission is stored, delivery failures stay visible instead of disappearing into email logs. If a notification bounces, you can see it, retry it, and still have the lead.

§ 03 · Setup How to connect it.

None of these steps involve writing server code. First, make sure you have the essentials in place:

Client submit handler

Use onSubmit to prevent the default reload and show inline state.

FormData

Build FormData from the form element so fields and files can be sent naturally.

Named inputs

React state names do not matter unless the rendered inputs also have name attributes.

Friendly feedback

Show a success or error message after the request finishes.

1
Keep the existing component — Do not rebuild the form UI. Add only the endpoint URL and submit handler.
2
Create FormData — Read the submitted form with new FormData(event.currentTarget).
3
POST to Formserve — Send the FormData to the endpoint URL and avoid adding a new API route unless the app has a strong reason.
4
Reset after success — Clear the form and show a short confirmation message.

§ 04 · Example Keep the form simple.

There's nothing special about the markup. The only required change is the action attribute. The hidden _honeypot input is the one spam-prevention field worth adding by hand:

react.html — minimal
function ContactForm() {
  async function handleSubmit(event) {
    event.preventDefault();
    const response = await fetch("https://formserve.io/f/YOUR_ENDPOINT_KEY", {
      method: "POST",
      body: new FormData(event.currentTarget)
    });

    if (response.ok) event.currentTarget.reset();
  }

  return (
    <form onSubmit={handleSubmit}>
      <input type="text" name="_honeypot" tabIndex="-1" autoComplete="off" style={{ position: "absolute", left: "-9999px" }} />
      <input type="email" name="email" required />
      <textarea name="message" required />
      <button type="submit">Send</button>
    </form>
  );
}
No fetch required for the basic case.

A plain action + method="POST" works with zero JavaScript. Reach for fetch only when you want to stay on the page and show a custom success state.

Before you launch

  • Check every input has a name attribute.
  • Show pending, success, and error states.
  • Test from the deployed domain.
  • Avoid exposing secrets; the endpoint URL is public.

Common mistakes

  • ! Only storing field values in React state and forgetting name attributes.
  • ! Creating an unnecessary Next/Express endpoint.
  • ! Not handling non-200 responses.
  • ! Resetting the form before the request succeeds.

Get a working endpoint in under a minute.

Paste the URL into your form's action and send a test. Free up to 100 submissions / month — no credit card.

Try without signup

§ 05 · FAQ Common questions.

Do I need to build a backend for a React contact form?
No. Formserve is the backend. You point the form at a Formserve endpoint URL and it stores submissions, filters spam, and sends notifications, so you never build or host a server yourself.
Does this work with React?
Yes. A React form submits standard named fields, and Formserve accepts them the same way any HTML form posts data — no SDK or plugin required.
Will connecting Formserve change my form design?
No. You keep your existing markup and styling. Only the submission behaviour changes so the form posts to your endpoint instead of a server you maintain.
How do I stop spam without a CAPTCHA?
Add the hidden _honeypot field shown in the code sample and set a spam protection level on the endpoint. Formserve blocks bots invisibly instead of showing a CAPTCHA.
FS
Formserve Team
We build the form backend behind thousands of HTML forms — from one-page contact forms to high-traffic launch pages.
React Guide No-code