Beginner4 minUpdated Mar 20, 2026

How to Add a Contact Form to Astro

Add a working contact form to your Astro site in minutes. No server endpoints, no API routes: just HTML and FormsList.

TL;DR

To add a contact form to an Astro site, create an HTML form with action set to `https://formslist.com/f/your-form-id`. Since Astro generates static HTML by default, a form backend like FormsList handles submissions without needing server endpoints or Astro API routes.

By Vaibhav Jain·Published March 20, 2026

Prerequisites

  • An Astro project
  • A FormsList account (free plan works)
1

Create a FormsList account

Sign up at formslist.com and create a new form. Copy the form hash from your dashboard; you'll need it for the form action URL.

2

Create the contact page

Create a new page in your Astro project at `src/pages/contact.astro`. Astro pages use `.astro` file format which supports standard HTML.

---
// src/pages/contact.astro
const title = 'Contact Us';
---

<html lang="en">
<head>
  <meta charset="UTF-8" />
  <title>{title}</title>
</head>
<body>
  <h1>{title}</h1>
  <form action="https://formslist.com/f/YOUR_FORM_HASH" method="POST">
    <label for="name">Name</label>
    <input id="name" name="name" type="text" required />

    <label for="email">Email</label>
    <input id="email" name="email" type="email" required />

    <label for="message">Message</label>
    <textarea id="message" name="message" rows="5" required></textarea>

    <button type="submit">Send</button>
  </form>
</body>
</html>
3

Replace YOUR_FORM_HASH

Replace `YOUR_FORM_HASH` in the form action with the hash from your FormsList dashboard. This is the unique identifier for your form endpoint.

4

Add a redirect (optional)

Add a hidden input to redirect users after submission: `<input type="hidden" name="_redirect" value="https://yoursite.com/thanks" />`

5

Deploy and test

Deploy your Astro site (Vercel, Netlify, Cloudflare Pages, etc.) and submit a test entry. Check the FormsList dashboard to verify the submission arrived.

Frequently Asked Questions

Does this work with Astro's static output mode?

Yes. Since FormsList handles the backend, your Astro site stays fully static. No server-side rendering or API routes needed.

Can I style the form with Tailwind CSS?

Absolutely. Astro supports Tailwind out of the box. Add Tailwind classes to your form elements just like any other Astro component.

Can I use Astro components for the form?

Yes. You can build the form as an Astro component or use React/Vue/Svelte islands for interactive features like client-side validation.

Ready to collect form submissions?

200 free submissions a month and a live endpoint in 30 seconds. No server, no credit card, just point your form at it.

Sign up with emailView pricing