Skip to content

Forms for static sites: Astro, Next.js, Hugo, Eleventy, plain HTML

Static hosting has no server to receive a form. Postbag is the server, and it does not care which host you use or whether you move.

Plain HTML

A <form action> and a _redirect. The post gets a 303 back to your thank-you page. No JavaScript, no build step.

fetch, React, Astro, Next.js

GET /v1/forms/{id}/embed returns snippets for each, rendered for your form's fields. Next.js server actions keep the submit URL off the client if you prefer; Astro and React post from the browser with an origin allowlist and CORS handled for you.

app/actions.ts
"use server"

export async function submitForm(formData: FormData) {
  await fetch("https://postbag.dev/s/fm_8f3kq2", { method: "POST", body: formData })
}

Host-independent

Netlify Forms only works on Netlify. Postbag works on Cloudflare Pages, Vercel, GitHub Pages, S3, a VPS, or all of them at once, and survives a migration because the form posts to Postbag, not to the host.

Questions, answered

Does Postbag work with Astro?
Yes. Use the HTML snippet (works with zero JS) or the fetch snippet from /v1/forms/{id}/embed.
Can I keep the submit URL secret?
It is not secret by design (it is in the HTML), which is why spam controls live on the form: honeypot, rate limit, origin allowlist and Turnstile.

Your first form is three minutes away.

Sign up, get a submit URL, point a form at it. The first submission lands in your inbox and your email. Everything else appears when you need it.