How-to · Checked November 22, 2026

How to add a contact form to a React app without a backend

Write a normal form in JSX, handle onSubmit, and post new FormData(event.currentTarget) to a form endpoint with fetch. One piece of state tracks whether it is sending, sent or failed. No backend, no library.

The endpoint comes from a form backend, which stores the message and emails you. It is safe to keep in front-end code because it can only receive submissions.

Steps

  • Create a form at a form backend and copy its endpoint. In FormTango it looks like https://formtango.com/f/YOUR_FORM_ID.
  • Add a component with a form and named inputs.
  • In onSubmit, call preventDefault and send the form with fetch.
  • Show a message based on the response.
  • Submit once and check the submission arrived.

The submit handler

Inside your component, with useState imported from React:

const [status, setStatus] = useState('idle');

async function send(event) {

event.preventDefault();

setStatus('sending');

try {

const response = await fetch('https://formtango.com/f/YOUR_FORM_ID', { method: 'POST', headers: { Accept: 'application/json' }, body: new FormData(event.currentTarget) });

setStatus(response.ok ? 'sent' : 'error');

} catch { setStatus('error'); }

}

The JSX

<form onSubmit={send}>

<label>Email <input type="email" name="email" required /></label>

<label>Message <textarea name="message" required /></label>

<input type="text" name="_gotcha" style={{ display: 'none' }} tabIndex={-1} autoComplete="off" />

<button disabled={status === 'sending'}>Send</button>

{status === 'sent' && <p role="status">Thanks! We got your message.</p>}

{status === 'error' && <p role="alert">Something went wrong. Please try again.</p>}

</form>

Why FormData and not controlled inputs

You do not need a useState for every field. FormData reads the current values straight from the form by their name attributes, so uncontrolled inputs are enough for a contact form. Controlled inputs are only worth it when the interface must react as the visitor types.

If you already hold the values in state, you can send JSON: set Content-Type to application/json and pass JSON.stringify(values) as the body. FormTango accepts both.

React details that trip people up

  • Attributes are camelCase in JSX: tabIndex, autoComplete, htmlFor, className.
  • Every input still needs a name. React does not add one.
  • Read event.currentTarget before any await if you need it later, or keep a reference to it.
  • Do not put a secret API key in a React app. Everything in the bundle is public. A form endpoint is not a secret.

More

A complete component is in the React guide, and there are versions for Next.js, Remix, Preact and Solid. The free plan covers 1,000 submissions a month with unlimited forms. Paid plans start at $9 a month.

Common questions

Can a React app send email without a backend?
Not directly, because a browser cannot send email. It can post the form to a form backend, which sends the email for you. No server of your own is needed.
Do I need a form library such as React Hook Form?
Not for a contact form. A form element, FormData and one fetch call are enough. A library helps when you have complex validation or many dependent fields.
Is it safe to put the form endpoint in my React code?
Yes. The endpoint only accepts submissions and cannot be used to read them. Requests to FormTango form endpoints are allowed from any website.

Written by the FormTango team. Facts about other services were read from their own pages on November 22, 2026. Spotted something out of date? Tell us and we will fix it.

Keep reading