Form Integration

Contact Form for Gatsby Sites

Easily create and integrate contact forms into your Gatsby site with zero backend setup. Simply use FormBold’s API endpoint to start collecting submissions instantly.

Contact Form for Gatsby

Gatsby Contact Form with Backend API

Add a fully functional contact form to your Gatsby site without writing backend code. With FormBold, simply paste your unique API endpoint into the form action attribute, and you're all set to start collecting submissions.

gatsby.tsx
import React, { useState } from "react";

export default function ContactForm() {
  const [loading, setLoading] = useState(false);
  const [responseMessage, setResponseMessage] = useState("");

  async function handleSubmit(event: React.FormEvent<HTMLFormElement>) {
    event.preventDefault();
    setLoading(true);

    const formData = new FormData(event.currentTarget);
    const json = JSON.stringify(Object.fromEntries(formData));

    try {
      const response = await fetch("https://formbold.com/s/FORM_ID", {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Accept: "application/json",
        },
        body: json,
      });
      const result = await response.json();

      if (response.ok) {
        setResponseMessage(result.message || "Message sent successfully!");
        (event.target as HTMLFormElement).reset();
      } else {
        setResponseMessage(result.message || "Something went wrong");
      }
    } catch (err) {
      setResponseMessage("Failed to submit form.");
    } finally {
      setLoading(false);
      setTimeout(() => setResponseMessage(""), 4000);
    }
  }

  return (
    <form onSubmit={handleSubmit} className="flex flex-col gap-4 max-w-[452px] mx-auto">
      {/* Email Address */}
      <div className="flex flex-col gap-2">
        <label htmlFor="email" className="text-sm font-medium text-gray-700">
          Email Address<span className="ml-0.5 text-red-500">*</span>
        </label>
        <input
          type="email"
          name="email"
          id="email"
          placeholder="Enter your email"
          required
          className="max-h-11 w-full rounded-xl border border-gray-300 bg-white px-4 py-2.5 text-base text-gray-900 transition-all placeholder:text-[#9ca3af] focus:border-[#5750f1] focus:ring-4 focus:ring-[#5750f1]/10 focus:outline-none"
        />
      </div>

      {/* Subject */}
      <div className="flex flex-col gap-2">
        <label htmlFor="subject" className="text-sm font-medium text-gray-700">
          Subject<span className="ml-0.5 text-red-500">*</span>
        </label>
        <input
          type="text"
          name="subject"
          id="subject"
          placeholder="Enter your subject"
          required
          className="max-h-11 w-full rounded-xl border border-gray-300 bg-white px-4 py-2.5 text-base text-gray-900 transition-all placeholder:text-[#9ca3af] focus:border-[#5750f1] focus:ring-4 focus:ring-[#5750f1]/10 focus:outline-none"
        />
      </div>

      {/* Message */}
      <div className="flex flex-col gap-2">
        <label htmlFor="message" className="text-sm font-medium text-gray-700">
          Message<span className="ml-0.5 text-red-500">*</span>
        </label>
        <textarea
          name="message"
          id="message"
          rows={5}
          placeholder="Type your message..."
          required
          className="w-full resize-y rounded-xl border border-gray-300 bg-white px-4 py-3 text-base text-gray-900 transition-all placeholder:text-[#9ca3af] focus:border-[#5750f1] focus:ring-4 focus:ring-[#5750f1]/10 focus:outline-none"
        />
      </div>

      {/* Submit Button */}
      <button
        type="submit"
        disabled={loading}
        className="flex h-12 w-full cursor-pointer items-center justify-center gap-2 rounded-xl bg-[#111827] px-5 py-3 text-base font-medium text-white shadow-xs transition-all hover:bg-black active:scale-[0.99] disabled:opacity-50"
      >
        {loading ? "Submitting..." : "Submit Message"}
      </button>

      {/* Status Notice */}
      {responseMessage && (
        <p className="rounded-xl p-3 text-center text-sm font-medium bg-gray-50 text-gray-800">
          {responseMessage}
        </p>
      )}
    </form>
  );
}
How it works

See How It Works

Setting up your Gatsby form with FormBold is quick and hassle-free—no need for complex configurations.

1

Create an Account

Sign up for FormBold and generate a unique API endpoint URL.

2

Paste the Action URL

Use the Gatsby form component and replace the action URL with your FormBold endpoint.

3

Start Receiving Submissions

Form submissions will be sent to the dashboard, inbox, or connected apps like Slack or Notion.

Features

Key Features of FormBold

FormBold provides powerful backend features for your Gatsby forms, while keeping it simple and code-free.

No Backend Required

Works seamlessly with Gatsby—no server setup, scripts, or backend code needed.

Instant Email Notifications

Get real-time notifications for form submissions delivered straight to your inbox or connected apps.

Spam Protection Built-In

Server-side validation and optional Google reCAPTCHA to prevent bot submissions.

File Upload Support

Let users upload files, and FormBold will automatically generate secure CDN links for file downloads.

Integrate with 5+ Apps

Connect to Slack, Notion, Google Sheets, and more—no code required.

FAQ's

Frequently Asked Questions

Here are answers to common questions about using FormBold with Gatsby.

Set the action attribute of your Gatsby form to the FormBold API endpoint, and select the POST method. No JavaScript or backend needed.

Gatsby Contact Form with Free Backend API (No Code Required) | Formbold