Skip to content

Astro

SubmitOwl works with both static (prerendered) and server-rendered (SSR) Astro pages using the same endpoint: https://api.submitowl.com/f/FORM_ID. Your FORM_ID is public and safe to render in HTML.

Create a contact form component or page such as src/pages/contact.astro:

---
const formEndpoint = "https://api.submitowl.com/f/FORM_ID";
---
<form id="contact-form" action={formEndpoint} 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>
<input type="hidden" name="_subject" value="Website contact" />
<input
type="text"
name="_gotcha"
tabindex="-1"
autocomplete="off"
aria-hidden="true"
style="display: none"
/>
<button type="submit">Send</button>
<p id="form-status" role="status"></p>
</form>

Without any client script, submitting this form performs a standard POST and redirects the visitor to an allowed _redirect URL, the form’s configured redirect URL, or the built-in /thanks page, in that order.

To keep visitors on the same page while falling back cleanly if JavaScript is unavailable, add a small script block to the same .astro file:

<script>
const form = document.getElementById("contact-form") as HTMLFormElement | null;
const status = document.getElementById("form-status");
form?.addEventListener("submit", async (event) => {
event.preventDefault();
if (status) status.textContent = "Sending...";
const response = await fetch(form.action, {
method: "POST",
body: new FormData(form),
headers: { Accept: "application/json" },
});
const data = await response.json();
if (data.ok) {
if (status) status.textContent = "Message sent.";
form.reset();
} else if (status) {
status.textContent = data.error?.message ?? "Submission failed.";
}
});
</script>

Both static builds and SSR Astro routes render the <form> markup into HTML on the server. That allows SubmitOwl’s page checks to find FORM_ID directly in the page HTML and verify that the form is still present, instead of falling back to reachability-only checks.

If you set the form’s origin mode to Only these origins (list) or Only my verified domains (verified), add your local dev server (http://localhost:4321) and preview deployment URLs to the form’s Allowed origins list. See Domains and origins.