splitforms.com

Contact form · Gatsby

Contact form for Gatsby websites

Gatsby is React under the hood, so any React form works — but the build is static. Use the splitforms endpoint to skip Netlify Forms (which limit submissions on free tier), Lambdas, Gatsby Functions, and AWS API Gateway entirely. One React component, 500 free submissions per month, dashboard included.

  • 500 free / mo
  • 14ms latency
  • No backend code
Gatsby contact form — copy-paste code for splitforms

No backend code

No server, API route, or SDK. Your Gatsby form posts straight to one endpoint.

Straight to your inbox

Every submission is emailed to you and saved to a searchable dashboard — spam filtered before it reaches you.

Design without limits

It's your own Gatsby markup and styles. Splitforms is only the backend, so nothing constrains how the form looks.

Copy-paste ready

Your Gatsby contact form, ready to paste.

Replace YOUR_ACCESS_KEY with the key from your dashboard — that's the whole integration. No SDK to install, no build step, just the jsx you already write.

Generate access key
contact.jsx
import React, { useState } from "react";

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

  async function handleSubmit(e) {
    e.preventDefault();
    setStatus("loading");
    const formData = new FormData(e.target);
    formData.append("access_key", "YOUR_ACCESS_KEY");

    const res = await fetch("https://splitforms.com/api/submit", {
      method: "POST",
      body: formData,
    });
    const data = await res.json();
    setStatus(data.success ? "ok" : "err");
    if (data.success) e.target.reset();
  }

  return (
    <form onSubmit={handleSubmit}>
      <input type="text"  name="name"    placeholder="Name"    required />
      <input type="email" name="email"   placeholder="Email"   required />
      <textarea           name="message" placeholder="Message" required />
      <input type="checkbox" name="botcheck" style={{ display: "none" }} tabIndex={-1} />
      <button type="submit" disabled={status === "loading"}>
        {status === "loading" ? "Sending…" : "Send"}
      </button>
      {status === "ok"  && <p>Thanks! We'll be in touch.</p>}
      {status === "err" && <p>Something went wrong. Try again?</p>}
    </form>
  );
}

How to add it

How to add a contact form to a Gatsby website.

To add a contact form to a Gatsby website you need three things: a free splitforms access key, the jsx snippet above, and your key pasted into it. No backend, server, or SDK — the form posts to one URL and every submission lands in your inbox and dashboard.

Get your free splitforms access key

Sign up at splitforms.com, verify your email, and copy your access key from the dashboard. No credit card required.

Drop the Gatsby snippet into your project

Copy the Gatsby code example into your project and replace YOUR_ACCESS_KEY with the key from step 1.

Receive submissions in your dashboard

Submissions arrive in the splitforms dashboard within seconds. Free includes inbox delivery; Pro adds Slack, Discord, Sheets, or any signed webhook URL.

Where submissions go

Where do your Gatsby form submissions go?

Every submission is emailed to you and saved to a searchable dashboard — spam filtered before it ever reaches you. Search, export to CSV, or forward it to a webhook or Slack on Pro.

  • 500 submissions per month, free forever
  • Honeypot + AI spam classifier on every plan
  • Signed webhooks to Slack, Discord, your server
Gatsby contact form submissions in the splitforms dashboard

No backend needed

Do you need a backend for a Gatsby form? No.

Your Gatsby form posts standard FormData to one URL. Splitforms validates the access key, runs the spam classifier, and forwards it to your email — so there's no server, API route, or database for you to build or maintain.

  • Plain React component — drop into any Gatsby page
  • No Netlify Forms, no Lambda, no Gatsby Functions required
  • Works with Gatsby Cloud, Netlify, Vercel, Cloudflare Pages, self-hosted
How splitforms processes a Gatsby form submission

Best practices

What a production-ready Gatsby form needs.

The difference between a form that works in the demo and one that survives launch traffic — the production-tested defaults, in priority order.

  • Use GATSBY_SPLITFORMS_KEY in your .env.production and .env.development files. Gatsby reads them at build time and inlines the value into the static JS bundle — that's expected, lock the key to your domain.
  • Don't wrap the form in <Link> or any component that intercepts navigation. Use a normal <form> element with onSubmit.
  • If you have multiple forms (contact, demo, newsletter), include a form-name hidden field per form so the splitforms dashboard groups them.
Production-ready Gatsby contact form best practices

How SplitForms works

From form to workflow in 3 simple steps.

Connect your form, collect every submission, and send data where it needs to go — without building backend infrastructure.

A SplitForms contact form submission launching straight to your inbox

Add your endpoint

Point your form to your unique SplitForms endpoint. That's it.

HTML form pointing at a SplitForms submit endpoint

Receive submissions

We instantly capture and organize every submission in your inbox.

Submissions inbox with searchable leads and status pills

Route anywhere

Send data to email, spreadsheets, CRMs, webhooks, and 7,000+ apps.

Generic integration tiles for email, sheets, chat, CRM, automate, and webhook

No credit card required. Set up in under 60 seconds.

Connect & automate

Connect your favorite tools and automate everything

SplitForms works with the destinations you route to and the platforms you build on — from Slack and Sheets to WordPress, Shopify, and Next.js.

Connect your SplitForms form to Slack, Google Sheets, Mailchimp, Zapier and more

Trusted by indie teams and agencies shipping forms worldwide

PETAL/COKRAFT.DELINEAR-XBUILD.DEVSTUDIO 71MERIDIANFRAME&CO

Testimonials

Loved by developers shipping at every scale.

40 quotes on record — from indie hacks to agency migrations.

Questions

Gatsby contact form questions.

View all FAQs
How do I add a contact form to Gatsby?

Drop the React component above into src/components/ContactForm.jsx, set GATSBY_SPLITFORMS_KEY in your .env, and import the component on any page. No plugin, no gatsby-config edits required.

Does splitforms work with Gatsby v4 and v5?

Yes — both. The component is a standard React function component, no Gatsby-specific APIs. For v5 partial hydration, add 'use client' at the top of the file so the onSubmit handler binds on the client.

How do I handle form errors in Gatsby?

Use a status state with four values: idle, loading, ok, err. Render error messages from data.message inside an {status === 'err' && …} block. The fetch returns { success, message? }.

Can I use splitforms with Gatsby Functions or Netlify Functions instead?

You can, but you don't need to. The whole point of splitforms is replacing the function. If you do want a server-side proxy (to hide the key entirely), POST from a Gatsby Function and forward to splitforms — same backend.

How do I customize the success / redirect behavior?

Two options. (1) Stay on-page with a React-rendered success message (default in our snippet), or call Gatsby's navigate() after success. (2) For a native form post, configure the absolute /thanks URL in Dashboard → Form settings → Redirect. Submitted redirect fields are ignored.

Will this work with Gatsby Cloud / Netlify / Vercel / Cloudflare Pages?

Yes — every host. The form posts to splitforms.com from the static page, regardless of where the static files are served from. Splitforms's allowed-domains list just needs to include your live URL.

GATSBY_ prefix required for env vars exposed at build time

Gatsby's webpack config only exposes process.env.* variables prefixed with GATSBY_. If you write process.env.SPLITFORMS_KEY, you'll get undefined in the browser bundle. Rename to GATSBY_SPLITFORMS_KEY — and accept that it's bundled into the static JS (lock the key to your domain in the splitforms dashboard).

Gatsby's <Link> can't wrap a form's submit handler

Gatsby's <Link> component prevents default navigation. Do not wrap the form in a Link. For fetch-based forms, call Gatsby's navigate('/thanks') after a successful response. For native form posts, configure the absolute thank-you URL in the splitforms dashboard.

SSR + client hydration mismatch on form initial state

If you use useState('idle') in your form and render any state-dependent UI on first paint, Gatsby's static HTML and React's client render can diverge — you'll see a hydration warning. Render the form unconditionally; only render status messages inside the handler-triggered branches.

Gatsby v5 partial hydration changed how forms hydrate

Gatsby 5 introduced partial hydration via React Server Components. If your form is in a Server Component, the onSubmit handler won't bind. Add 'use client' at the top of the file (or use a separate ContactForm.client.jsx).

@reach/router (legacy) intercepts form submits with onSubmit handlers

Older Gatsby setups used @reach/router, which has a known issue where it sometimes intercepts form submissions. If you see your form not POSTing, ensure you've migrated to Gatsby v4+ (uses its own router) or wrap the form in a normal <div> not <Router>.

gatsby-plugin-offline caches the contact page and serves a stale form

If your site uses gatsby-plugin-offline (or the older gatsby-plugin-manifest with service worker registration), the contact page HTML is cached aggressively. After you rotate your GATSBY_SPLITFORMS_KEY and redeploy, returning visitors keep submitting against the old key from the cached bundle until the service worker fetches a fresh shell — sometimes days. Fix: bump the SW cache version in gatsby-config.js on key rotation, or skip the offline plugin on the contact route via runtimeCaching rules. Alternatively, switch to gatsby-plugin-pwa which handles versioned cache invalidation per-page.

How does Gatsby handle forms without splitforms?

Gatsby builds a static React app, so 'native' means choosing between (a) Netlify Forms for Gatsby sites hosted on Netlify, with gatsby-plugin-netlify required, (b) Gatsby Functions (deprecated in Gatsby 5 — they were removed when Gatsby Cloud shut down), or (c) a third-party form backend. Gatsby v4 had Functions running as Lambda-equivalent serverless routes; v5 removed them entirely. Result: every Gatsby contact form today uses an external service. Splitforms is the portable drop-in option — the same POST shape as Netlify Forms or Formspree, with built-in spam filtering.

Any deployment notes for shipping Gatsby to production?

Gatsby builds static HTML + JS that deploys to any host: Netlify, Vercel, Cloudflare Pages, AWS Amplify, S3 + CloudFront, Gatsby Cloud (sunset 2024 — migrate). The form posts cross-origin to splitforms regardless of host. Env vars exposed to the browser bundle must be prefixed GATSBY_ — anything else is undefined client-side. The key gets bundled into the JS at build time; lock it to your domain in the splitforms dashboard. For headless Gatsby + WordPress / Contentful setups, the form lives in the React tree, not the CMS — no special CMS wiring required.

Simple pricing

Start free. Scale when you need more.

Choose a plan that fits your workflow — from a free form endpoint to full automations, exports, and higher submission limits.

Free

$0

Free forever

 
Best for testing

For side projects and indie devs.

  • 500 submissions / mo
  • Unlimited forms
  • Email notifications included
  • Honeypot spam filtering
  • Submissions dashboard
  • MCP setup stays free
  • No credit card required

3-Year

$59/ 36 months
was $99 · save 40% · new-user price

Pay $59. 3 years sorted.

  • 15,000 submissions / mo
  • Unlimited forms
  • Everything in Pro
  • Renews every 3 years
  • Long-term discount
  • Priority support included
  • Vote on the roadmap

No credit card required on Free • Cancel anytime