Skip to content
FormToMail

Contact forms on static sites and frameworks

Static hosts serve files and run no code when someone submits a form. You either add a serverless function of your own or point the form at a form endpoint. Each guide covers both, framework by framework.

How do I add a contact form to an Astro site?

Astro builds static HTML by default, and a static page can't receive a POST. You have two options: point the form at a form endpoint (works on any static Astro build, zero server code), or enable on-demand rendering with an adapter and handle the POST in an Astro Action or API endpoint that sends the email through a provider such as Resend.

How do I handle forms in a Next.js static export (output: 'export')?

With output: 'export', Next.js lists Server Actions and Route Handlers that rely on the Request as unsupported, because there is no Node.js server. Forms in a static export must be submitted from a client component (or a plain HTML action) to an external form endpoint or API.

How do I add a contact form to a Hugo site?

Hugo generates static files and has no built-in form handling, so a Hugo contact form is plain HTML whose action points to a form endpoint (or to Netlify Forms if you host on Netlify). Put the form in a partial or shortcode so you can drop it into any page or layout.

How do I handle form submissions on Cloudflare Pages?

Cloudflare Pages has no built-in form collection like Netlify Forms. Either write a Pages Function (a file in /functions that handles the POST, validates a Turnstile token server-side, stores rows in D1 and sends email via an API), or point the form at a form endpoint and skip the code.

How do I add a contact form to a GitHub Pages or Jekyll site?

GitHub Pages is static hosting: it serves your HTML, CSS and JavaScript and runs no server code, so a form there must post to an external form endpoint. In Jekyll, put the form in an include (for example _includes/contact.html) and add {% include contact.html %} where you want it.

How do I add a working contact form to an 11ty (Eleventy) site?

Eleventy is a static site generator, so a contact form is plain HTML in an include or template whose action is a form endpoint. Nothing to install: the form posts straight to the endpoint, which emails you and redirects the visitor back to a thank-you page.

Make your form email you

Paste one URL into your form and every submission is emailed to you, spam filtered. Free for 250 a month.

Get your endpoint