Astro Contact Form Without Serverless Functions
Astro is designed to generate fast, lightweight static sites. By default, it outputs static HTML with no backend runtime. This makes it ideal for blogs, documentation, landing pages, and marketing sites. However, it also means Astro cannot process form submissions on its own.
Many developers assume they need serverless functions to handle contact forms in Astro. In reality, you can avoid serverless entirely by using a backendless form service like Fabform. With a single endpoint, you can add a fully functional contact form to any Astro site without writing backend code.
If you are exploring other Astro or static‑site form setups, these guides may also help:
- Build an Astro Blog With a Fabform Contact Form
- Astro Template With Fabform Contact Form
- The Fastest Way to Add Forms to Static Sites
Why Astro does not need serverless functions for forms
Astro’s static output means:
- no server‑side processing
- no built‑in email sending
- no backend storage
- no form handling
A traditional HTML form will not work without a backend to receive the submission.
Fabform solves this by providing:
- a secure form endpoint
- spam protection
- email, Slack, and webhook notifications
- a submission dashboard
- CSV export
- GDPR‑friendly storage
Your Astro site stays static.
Your form becomes fully functional.
Step 1 — Create your Fabform endpoint
- Visit https://fabform.io
- Create a free account
- Select “Create New Form”
- Copy your unique form endpoint:
https://fabform.io/f/your-form-id
If you want to compare Fabform with other services, see:
Fabform vs Formspree
Step 2 — Create a contact page in Astro
Create a new file:
src/pages/contact.astro
Add the following markup:
---
title: "Contact"
---
<h1>Contact</h1>
<form action="https://fabform.io/f/your-form-id" method="POST">
<label>
Name
<input type="text" name="name" required />
</label>
<label>
Email
<input type="email" name="email" required />
</label>
<label>
Message
<textarea name="message" required></textarea>
</label>
<button type="submit">Send Message</button>
</form>
This form works immediately.
No JavaScript.
No serverless functions.
No backend code.
Step 3 — Style your form
Astro supports any CSS approach.
Here is a simple example using a <style> block:
<style>
form {
max-width: 500px;
margin: 2rem 0;
display: flex;
flex-direction: column;
gap: 1rem;
}
input, textarea {
padding: 0.75rem;
border: 1px solid #ccc;
border-radius: 6px;
}
button {
padding: 0.75rem;
background: #000;
color: #fff;
border: none;
border-radius: 6px;
cursor: pointer;
}
</style>
Step 4 — Test your form
Start your local server:
npm run dev
Visit:
http://localhost:4321/contact
Submit a test message.
You will see it appear instantly in your Fabform dashboard.
Step 5 — Deploy your Astro site
Astro can be deployed to:
- Netlify
- Vercel
- Cloudflare Pages
- GitHub Pages
- Any static host
If you are using one of these platforms, you may find these guides helpful:
- Netlify Contact Form Tutorial
- Cloudflare Pages Contact Form Tutorial
- Add a Serverless Contact Form to GitHub Pages
Step 6 — Add spam protection
Fabform includes built‑in spam filtering, but you can add an optional honeypot field:
<input type="text" name="website" style="display:none" tabindex="-1" autocomplete="off" />
Bots fill this field.
Humans do not.
Fabform ignores submissions that include it.
Troubleshooting
Form not submitting
Verify your action attribute:
https://fabform.io/f/your-form-id
Not receiving notifications
Check your Fabform notification settings.
Want a prebuilt Astro template
See:
Astro Template With Fabform Contact Form
Related Posts
- Build an Astro Blog With a Fabform Contact Form
- The Fastest Way to Add Forms to Static Sites
- Netlify Forms Alternative for Static Sites
- Netlify Forms Not Working? Fix It Fast
Final Thoughts
Astro’s strength lies in its ability to produce fast, static sites without unnecessary complexity. By pairing it with a backendless form service, you avoid the overhead of serverless functions while still gaining a dependable way to collect submissions.
If you want to extend this setup further, explore how Fabform integrates with other static hosts and frameworks. It gives you a consistent, reliable form backend whether you deploy to Netlify, GitHub Pages, Cloudflare Pages, or any other static platform.