Skip to content
Wrenform

Docs / Frameworks

Contact form for Vue and Nuxt

A single-file component for Vue 3 or Nuxt that posts with fetch and shows the result inline.

Last updated 2026-11-14View as Markdown
<!-- ContactForm.vue (Vue 3 / Nuxt) -->
<script setup>
import { ref } from "vue";
const status = ref("idle");

async function onSubmit(e) {
  const form = e.target;
  status.value = "sending";
  try {
    const res = await fetch("https://wrenform.com/f/YOUR_FORM_ID", {
      method: "POST",
      headers: { Accept: "application/json" },
      body: new FormData(form),
    });
    status.value = res.ok ? "sent" : "error";
    if (res.ok) form.reset();
  } catch {
    status.value = "error";
  }
}
</script>

<template>
  <form @submit.prevent="onSubmit">
    <label>Name <input type="text" name="name" autocomplete="name" required /></label>
    <label>Email <input type="email" name="email" autocomplete="email" required /></label>
    <label>Message <textarea name="message" required></textarea></label>
    <input type="text" name="_honey" style="display:none" tabindex="-1" autocomplete="off" />
    <button type="submit" :disabled="status === 'sending'">Send</button>
    <p role="status">
      <span v-if="status === 'sent'">Thanks, your message was sent.</span>
      <span v-if="status === 'error'">Something went wrong. Please try again.</span>
    </p>
  </form>
</template>

Steps

  1. Create a form and copy its form ID, or let your AI tool create one without an account.
  2. Save the component as ContactForm.vue (in components/ for Nuxt, so it's auto-imported) and replace YOUR_FORM_ID.
  3. Use it on a page: <ContactForm />. In Nuxt, create pages/contact.vue for a /contact route.
  4. Deploy. Then add your site's origin under Allowed origins in the form's settings.

No server route needed. In Nuxt you don't need a server/api handler: the browser posts straight to Wrenform. The form ID is public by design.

On Nuxt, the Nuxt guide has a component that posts with $fetch and works before hydration. In Nuxt you can keep the ID in runtimeConfig.public. In plain Vue with Vite, use import.meta.env.VITE_WRENFORM_ID.

Without JavaScript

A plain <form action="https://wrenform.com/f/YOUR_FORM_ID" method="POST"> also works in any Vue template, including statically generated Nuxt pages. Visitors leave the page and come back through a redirect. See redirects.

Test it

Run the dev server, open the page and send the form. You should see the thank-you line, the submission in your dashboard and an email. While testing locally, leave Allowed origins empty or add your dev origin, such as http://localhost:3000.

Common problems

  • CORS error. The page's origin isn't in the form's allowed origins.
  • empty_submission. The inputs need name attributes. v-model alone doesn't add them.
  • Hydration mismatch warning in Nuxt. A browser extension changed the form. It doesn't affect the submission.
  • Strict CSP. Add connect-src https://wrenform.com.

Next steps

Something wrong or unclear on this page? Report a problem: write to hello [at] wrenform.com with the page address (/docs/frameworks/vue).