Target query: “react contact form without backend

React Contact Form Handler — Send to Email with No Server

Submit React form inputs directly to email without Node.js or server setups. Works with React Hook Form, Formik, and simple fetch calls.

Quick Summary

How do you handle form submission in React without a backend?
Use standard fetch or axios to post state data to a form backend endpoint like SendMyForm. This allows you to collect client-side inputs and receive them as structured emails.

Example Integration Code

import { useState } from 'react';

export default function ContactForm() {
  const [status, setStatus] = useState('');

  const handleSubmit = async (e) => {
    e.preventDefault();
    const data = new FormData(e.target);
    
    setStatus('Submitting...');
    const response = await fetch('https://sendmyform.live/api/f/YOUR_FORM_ID', {
      method: 'POST',
      body: data,
      headers: {
        'Accept': 'application/json'
      }
    });

    if (response.ok) {
      setStatus('Thank you for your message!');
      e.target.reset();
    } else {
      setStatus('Something went wrong. Please try again.');
    }
  };

  return (
    <form onSubmit={handleSubmit} className="space-y-4">
      <input type="text" name="name" placeholder="Name" required />
      <input type="email" name="email" placeholder="Email" required />
      <textarea name="message" placeholder="Message" required />
      <button type="submit">Send</button>
      <p>{status}</p>
    </form>
  );
}

In contemporary Single Page Application (SPA) development, spinning up a full server for a simple contact form is overkill. React developers often leverage static hosts like Netlify or Vercel, which are highly optimized for frontend performance but lack server-side environments.

Integrating with React Hook Form

If you are using react-hook-form for client-side validation and state management, you can submit values to SendMyForm just as easily:

const { register, handleSubmit } = useForm();
const onSubmit = data => {
  fetch('https://sendmyform.live/api/f/YOUR_FORM_ID', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify(data)
  });
};

This retains full control over your client UI and loading states while delegating notifications, validation, and email formatting to SendMyForm.

Connect your form today.

No credit card required. Free tier includes 100 submissions per month with instant setup.

Get Started Free

Related Resources