Use a plain HTML form in an .astro page, or fetch() JSON, without adding an Astro endpoint.
You can add a contact form to an Astro site withoutsrc/pages/api.
Plain HTML in any .astro file:
<form action="https://formcask.com/f/f_YOUR_FORM_ID" method="POST"> <input type="text" name="name" required /> <input type="email" name="email" required /> <textarea name="message" required></textarea> <input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off" /> <button type="submit">Send</button> </form>With fetch, for a custom success state:
const res = await fetch("https://formcask.com/f/f_YOUR_FORM_ID", {
method: "POST",
headers: { "content-type": "application/json", accept: "application/json" },
body: JSON.stringify({ name, email, message }),
});
const data = await res.json();
This works with static output (output: 'static') and does not need an Astro adapter. File uploads require the Pro plan and multipart/form-data.