splitforms.com

Contact form · Astro

Contact form for Astro websites

Astro's zero-JS-by-default philosophy pairs perfectly with the splitforms endpoint. Use a pure HTML form for static pages, an Astro Action for SSR, or a React/Vue/Svelte island for client-side interactivity. Same backend, three patterns, zero hydration cost when you don't need it.

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

No backend code

No server, API route, or SDK. Your Astro 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 Astro markup and styles. Splitforms is only the backend, so nothing constrains how the form looks.

Copy-paste ready

Your Astro 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 astro you already write.

Generate access key
contact.astro
---
const ACCESS_KEY = import.meta.env.PUBLIC_SPLITFORMS_KEY;
---

<form action="https://splitforms.com/api/submit" method="POST">
  <input type="hidden" name="access_key" value={ACCESS_KEY} />

  <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">Send</button>
</form>

How to add it

How to add a contact form to a Astro website.

To add a contact form to a Astro website you need three things: a free splitforms access key, the astro 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 Astro snippet into your project

Copy the Astro 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 Astro 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
Astro contact form submissions in the splitforms dashboard

No backend needed

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

Your Astro 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.

  • Zero JavaScript shipped — pure HTML form action
  • Works with Astro Islands, SSR, and the new Astro Actions API
  • Pull access key from import.meta.env so it never lands in the bundle
How splitforms processes a Astro form submission

Best practices

What a production-ready Astro 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 the pure HTML form pattern (the snippet above) for static pages — zero JS shipped, no hydration cost, works with JavaScript disabled.
  • Set PUBLIC_SPLITFORMS_KEY in .env and reference it in the Astro frontmatter. Lock the key to your domain in the splitforms dashboard so a leaked key can't be replayed.
  • Configure the absolute /thanks URL in Dashboard → Form settings → Redirect so non-JS users still land on a thank-you page after submitting.
Production-ready Astro 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

Astro contact form questions.

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

Paste the snippet above into any .astro page or component. Set PUBLIC_SPLITFORMS_KEY in your .env file. That's it — no install, no astro:integrations, no adapter changes.

Does splitforms work with Astro SSR and SSG?

Yes — both. In SSG (output: 'static') the form posts directly to splitforms.com from the browser. In SSR (output: 'server' or 'hybrid') you can additionally use Astro Actions to keep the key server-side. Pick whichever fits.

How do I handle form errors in Astro?

If you're using Astro Actions, render result?.error?.message from Astro.getActionResult(actions.contact). A pure HTML submission uses splitforms's built-in error page; use fetch or an Astro Action when you need a custom inline error state.

Can I use splitforms with Astro Islands (React, Vue, Svelte, Solid)?

Yes. Build the form as a React/Vue/Svelte component, hydrate with client:visible or client:idle, and use the framework-specific snippet from the matching /forms/<framework> page.

How do I customize the success / redirect behavior?

Configure /thanks in Dashboard → Form settings → Redirect and splitforms will send the browser there after a successful native POST. A submitted redirect field is ignored. With Astro Actions, render success state from result.data or navigate in your action instead.

Will splitforms add 1KB of JS to my Astro site?

No. The default snippet uses zero JavaScript — it's a vanilla <form action method=POST>. JavaScript only runs if you choose the island pattern or wire up custom client-side validation.

PUBLIC_ prefix is required for client-exposed env vars

Astro mirrors Vite's env-var convention: only variables prefixed with PUBLIC_ are exposed to client-side code (and to .astro files when output: 'static'). If you write import.meta.env.SPLITFORMS_KEY, you'll get undefined at build time. Rename to PUBLIC_SPLITFORMS_KEY.

client:load on the form island defeats the point of Astro

If you wrap the form in <MyForm client:load />, you ship a full React/Preact runtime just for one form. Use client:visible (load when scrolled into view) or client:idle (load after main thread is free) instead. For zero-JS forms, skip the island entirely and use a plain HTML form action.

Astro Actions need a try/catch or they crash the page

If your action throws, Astro 5's behavior is to render an error page rather than return the error to your form. Wrap the splitforms fetch in try/catch and return { success: false, message } from the action — your form component can then render the message.

View Transitions can break form re-submit state

If you've enabled <ViewTransitions /> in your layout, navigating to /contact and back may re-mount the form mid-submission. Add data-astro-reload to the form's submit anchor or guard with if (status === 'loading') return at the top of your handler.

Adapter mismatch: form posts to /api/submit fail in static mode

If output: 'static' in astro.config.mjs, you can't have a server endpoint at all — your form must POST directly to splitforms.com. That's the recommended setup. Switch to output: 'server' or 'hybrid' only if you genuinely need a server-side proxy.

Frontmatter fence forgotten — form action renders as literal text

Astro requires the --- fence at the top of .astro files for any frontmatter (imports, Astro.props, env reads). If you write const accessKey = import.meta.env.PUBLIC_SPLITFORMS_KEY; without the surrounding fence, Astro treats the line as plain text in the rendered HTML — you'll see the JavaScript leak into the page above your form. The build doesn't error; it just renders nonsense. Always wrap any logic in --- and reference values via {accessKey} in the template body.

How does Astro handle forms without splitforms?

Astro's whole pitch is shipping zero JavaScript by default. A native contact form on Astro means either (a) building a form with no submission target — useless — or (b) standing up an API endpoint via output: 'server' or 'hybrid', which means writing a Node/Bun/Deno handler, picking an email provider, writing your own honeypot logic. Astro 5 added typed Actions, but they're a wrapper around the same underlying fetch — you still deliver the email yourself. The result: every Astro contact-form tutorial ends with 'now configure SendGrid'. Splitforms is the SendGrid-replacement that doesn't require an account, an API key for the email provider, or DNS records for SPF/DKIM.

Any deployment notes for shipping Astro to production?

Astro deploys cleanly to Vercel, Netlify, Cloudflare Pages, GitHub Pages, and any static host with output: 'static'. For Astro Actions (Pattern B), you need output: 'server' or 'hybrid' and a matching adapter (@astrojs/vercel, @astrojs/netlify, @astrojs/cloudflare). On Cloudflare Pages with the Cloudflare adapter, the Action runs in a Worker — keep the splitforms fetch tight (no extra proxying) to stay under the 10ms CPU budget on the free plan. The PUBLIC_ prefix is mandatory for env vars exposed to client-rendered .astro files; vars without it are silently undefined. Lock the key to your *.pages.dev and custom domain.

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