Formpost

Framework guides

Vue

A single-file component with submit handling.

Use @submit.prevent to keep the page in place, then post the form's FormData. The pattern is identical in Nuxt.

ContactForm.vue
<script setup>
import { ref } from "vue";

const sent = ref(false);

async function submit(event) {
  const body = new FormData(event.target);
  body.append("access_key", "YOUR_ACCESS_KEY_HERE");

  const res = await fetch("https://api.formpost.ai/submit", {
    method: "POST",
    headers: { Accept: "application/json" },
    body,
  });

  sent.value = (await res.json()).success;
}
</script>

<template>
  <form @submit.prevent="submit">
    <input name="name" required />
    <input type="email" name="email" required />
    <textarea name="message" required />
    <button type="submit">Send</button>
    <p v-if="sent">Thanks — we will be in touch.</p>
  </form>
</template>