Skip to content
Lazyform

Contact form for Astro

Add a contact form to your Astro site that works with zero JavaScript. Keep the site fully static and get every message by email, Telegram or Slack.

Free plan: 250 submissions a month, forever.

Why a form backend for Astro

Astro sites are often fully static: fast pages, no server, cheap or free hosting. A contact form is usually the one thing that pushes people towards adding an SSR adapter and an API endpoint.

You don't need to. Point the form at Lazyform and your site stays static. Spam checks, storage and delivery run on our side, and the form keeps working even if JavaScript fails to load.

A working contact form

Create a component and replace YOUR_ACCESS_KEY with your key from /login.

src/components/ContactForm.astro
---
const accessKey = 'YOUR_ACCESS_KEY'
const thanksUrl = new URL('/thanks', Astro.site ?? Astro.url).href
---

<form id="contact" action="https://lazyform-api.xvelopers.com/submit" method="POST">
  <input type="hidden" name="access_key" value={accessKey} />
  <input type="hidden" name="redirect" value={thanksUrl} />
  <input type="text" name="name" placeholder="Name" required />
  <input type="email" name="email" placeholder="Email" required />
  <textarea name="message" placeholder="Message" required></textarea>
  <input type="checkbox" name="botcheck" class="hidden" style="display:none" />
  <button type="submit">Send</button>
  <p id="contact-status" role="status"></p>
</form>

<script>
  const form = document.querySelector<HTMLFormElement>('#contact')!
  const status = document.querySelector<HTMLParagraphElement>('#contact-status')!

  form.addEventListener('submit', async (event) => {
    event.preventDefault()
    status.textContent = 'Sending…'
    const res = await fetch(form.action, {
      method: 'POST',
      headers: { Accept: 'application/json' },
      body: new FormData(form),
    })
    const data = await res.json()
    status.textContent = data.success ? 'Thanks! Message sent.' : data.error.message
    if (data.success) form.reset()
  })
</script>

Without JavaScript, the form posts normally and the visitor lands on your /thanks page. With JavaScript, the script takes over and shows the result inline. Set site in astro.config.mjs so the thank-you URL points at your real domain.

Get submissions where you want them

Messages arrive by email. You can also get Telegram, Slack, Discord or WhatsApp alerts, or copy each submission into Google Sheets, Notion or Airtable. See all integrations.

Full guide

The Astro guide covers environment variables, islands, file uploads and spam protection options.

Questions

Does my Astro site need an SSR adapter?

No. The form posts directly to Lazyform, so a fully static Astro build works. You don't need an adapter, an API endpoint or Astro Actions.

Does it ship any JavaScript?

The form itself needs none. The optional script in the example adds a few lines so the page doesn't reload, and Astro bundles it for you.

Can I use it inside a React, Vue or Svelte island?

Yes. Use the guide for that framework and render the component as an island with a client directive such as client:visible.

Where do I put the access key?

Inline it, or read it from an environment variable with import.meta.env. The key is public by design: it can send submissions, not read them.