FORMDALL & ASTRO

Forms in Astro - without the server Astro deliberately leaves out

5 min read·Astro 5, 6 & 7

Astro renders your site to plain HTML and ships zero JavaScript by default. You write components with a frontmatter block on top and markup below, pull content through Content Collections with a typed schema, and at the end of the build there is a folder: HTML, CSS, images. The bundle holds neither a framework runtime nor hydration you then have to switch off again. That is why people move to Astro.

Why people move to Astro

In Astro, interactivity is an exception you declare. A React, Vue or Svelte component stays static HTML until you write client:load, client:visible or client:idle next to it. Anything you do not mark costs zero kilobytes, and every island shows up in the diff as a deliberate decision.

The difference to Next.js only shows up in what one interactive component costs. In both, rendering happens outside the browser unless you say otherwise; in the App Router, Server Components are the default. They part company where something has to run in the browser. 'use client' marks a boundary, and everything that file imports and renders directly lands behind it - React itself included. In Astro the boundary is the island: out goes that one component’s JavaScript plus the framework runtime, which loads once for the page rather than once per boundary, and whatever you hand it as children stays static HTML. The rest of the page stays at zero because nobody marked anything there.

On top of that, Astro does not tie you to one UI framework. Content Collections give your Markdown files a Zod schema that the build enforces, instead of a missing field surfacing as undefined in a template. One island can be React while the one next to it is Svelte, so for a mixed stack you import the component you already have instead of rewriting it.

That does not hold everywhere. If your product is a dashboard with shared state across twenty routes, Next.js is the better tool. For marketing sites, docs, blogs and anything that is 90 percent text, the inverted default is the better starting point.

What a static build cannot do

A static build has no process waiting for the POST. Your CDN serves files, and a POST request to an .html comes back as a 405 if you are lucky. You cannot hold that against Astro, because that is what static means.

The way out is documented, and it costs more than it appears to. Astro prerenders everything by default - output is set to 'static'. For a route to accept a POST request, it has to be rendered on demand: either export const prerender = false in that one route, or output: 'server' for the whole project. Both require an adapter, so @astrojs/node, Vercel, Netlify or Cloudflare. Without an adapter there is no target Astro could deploy the server-rendered routes to in the first place.

Astro Actions do not change this. They are the nicer API for form submissions, with Zod validation and a type-safe call, but they stand on the same foundation: no action runs without an adapter, and calling one as a form action additionally requires the page to be rendered on demand.

Your deployment looks different from that point on. “astro build, upload dist/” turns into a runtime that keeps running: a Node version that will age, a cold start, a log somebody has to read, an invoice per invocation. For a form with three fields you give up precisely what you picked Astro for.

And the adapter is only the transport. The actual work still lies ahead of you: validate input on the server, get mail delivered without landing in the spam folder, keep out the spam coming the other way, and decide where the data lives and when it disappears again.

Wiring it up

The route you just did not switch to on-demand rendering can still carry a form. An absolute action sends the POST to a foreign domain without an adapter having to stand in between; method stays POST, and the rest is the markup you would have written anyway.

src/pages/contact.astro
---
import Base from '../layouts/Base.astro';
---

<Base title="Contact">
  <!-- without an adapter or a function, served as plain static output -->
  <form action="https://api.formdall.de/api/v1/f/kx92m4" method="POST">
    <input name="name" required />
    <input name="email" type="email" required />
    <textarea name="message"></textarea>
    <button>Submit</button>
  </form>
</Base>

The route stays prerendered. prerender = false and the adapter in astro.config.mjs stay unused, and the browser runs not one byte of JavaScript. After submitting, the visitor lands on the thank-you page you set for this form.

If you would rather handle the answer on the page, a <script> goes under the form and sends the POST via fetch() with Accept: application/json; the same URL then answers with JSON instead of a redirect. The endpoint is the same one and the config stays untouched. This one page picks up a few lines of JavaScript, which still is not an island. You can have the markup written for you too. The MCP server calls create_form with your field list, get_embed hands back the snippet, and your editor puts it into the .astro file.

What you are not building

Between the submit click and your inbox lies a chain of checks. All of it runs server-side, so none of it turns into an island and it weighs zero kilobytes in your bundle. No third-party widget goes into your markup. Cookies are the reason most captchas drag a consent banner along; this one sets none, so the question never comes up. If a hurdle does have to come between visitor and form, it is a proof-of-work captcha running on our own servers. It skips cookies and tracking entirely, and nothing is sent to a US server.

The submissions themselves sit on servers in Germany, encrypted inside the database. Once their retention period has run out, a daily job deletes them for real; there is no flag called deleted_at that merely makes them invisible.

You can build all of it yourself. You just bring back the adapter you did not install above, and with it SPF, DKIM and DMARC, a sending domain whose reputation has to be maintained, and spam rules that have to keep up when the next wave has a different shape. In Astro you pay for runtime only where you declare it, whereas your own form backend would be a runtime you never marked and still have to carry permanently. Three forms and 100 submissions a month are free, and nobody asks for a credit card. The deploy does not change either: astro build, upload dist/.

OR: LET THE AI DO IT
YouBuild me a contact form for my Astro site with name, email and message.
Assistant formdall · create_form formdall · get_embedForm created, schema set. Here is the component:
<form action="https://api.formdall.de/api/v1/f/kx92m4" method="POST">
  <input name="name" required />
  <input name="email" type="email" required />
  <textarea name="message"></textarea>
  <button>Submit</button>
</form>
→ read the MCP docs

Create an endpoint and embed it

Start for freeno credit card, ever
  • Free
  • 3 forms
  • 100 submissions/mo