Docs / Contact form guides
Add a contact form to a Vue (Vite) site
A Vue 3 (Vite) contact form from one prompt or one single-file component, with a thank-you route.
Add a working contact form to this Vue 3 (Vite) project. Create the form by sending POST https://wrenform.com/api/v1/quick-forms with JSON {"email": "YOUR_EMAIL", "framework": "vue"} (if you can't make HTTP requests, give me the curl command to run). Put the returned snippet on a /contact page or section, matching the site's style: a label for each field, type="email" on the email field, and keep the _honey field exactly as returned. Show a thank-you message after sending and an error message on failure. Put the form in src/components/ContactForm.vue and the form ID in .env as VITE_WRENFORM_ID. Add no dependencies, API keys or server code. Then tell me to check my inbox for the Wrenform email and click Confirm, because messages are held until I do.Replace YOUR_EMAIL with the address that should get the messages, and paste. This creates a form without an account: no sign-up, no mail provider, free for 250 submissions a month. Nothing is forwarded until you click Confirm in the email we send, and unconfirmed forms are deleted after 7 days. Prefer the dashboard? Create a form and use the snippet below.
A Vue app built with Vite runs in the browser, so there is no server to receive a form. Wrenform is the HTTPS endpoint the component posts to; the form ID is public, so it can sit in client code.
Steps
- Start from a Vite project (
npm create vue@latest), or use the one you have. - Paste the prompt into your coding tool, or save the component below as
src/components/ContactForm.vue. - Render
<ContactForm />on your contact page or route. - Click Confirm in the email from Wrenform, then deploy.
Lock the form to your site. A form created this way accepts posts from any site. Once you've confirmed, sign in with the same address and add your published domain under Allowed origins in the form's settings, for example https://example.com.
Or paste the code
<!-- 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>Every input needs a name: FormData sends only named fields, and v-model doesn't add one.
Keep the form ID in .env
Put VITE_WRENFORM_ID=YOUR_FORM_ID in .env, then build the URL in the component:
const endpoint = "https://wrenform.com/f/" + import.meta.env.VITE_WRENFORM_ID;Use endpoint in the fetch call. Vite exposes only variables that start with VITE_, and reads .env when the dev server starts.
A thank-you route with Vue Router
To send visitors to their own page instead of the inline line, add a route and push to it on success:
{ path: "/thanks", component: () => import("../views/ThanksView.vue") }In the component, call useRouter() from vue-router in <script setup>, and replace status.value = res.ok ? "sent" : "error" with if (res.ok) router.push("/thanks"); else status.value = "error";. A plain form without JavaScript uses Redirect to in the form's settings instead; see redirects.
Spam and email
- The hidden
_honeyfield catches most bots. Keep it in the form, hidden, withautocomplete="off". - A timing check marks submissions sent less than 3 seconds after the form loaded as spam, when the form sends the timing field. The optional script in the HTML snippet adds it; see the timing field. No captcha is needed.
- Each real submission is emailed to you and shown in your dashboard.
- Submissions are stored in the EU. Free keeps them for 30 days, paid plans for 365 days.
Test it
Run npm run dev, open the contact page and send the form. After confirming, the message is in your inbox and your dashboard. Send one more from the deployed site.
Common problems
- The form sends but no email arrives. The address hasn't confirmed yet. Look for the email from Wrenform, also in spam.
empty_submission. The inputs havev-modelbut noname. Add anameto each.403 origin_not_allowed. The page's origin isn't in the form's Allowed origins. Add it, including any preview domain. See errors.- The URL ends in
/f/undefined.VITE_WRENFORM_IDisn't set. Check the name and restartnpm run dev. - Anything else. See troubleshooting.
Next steps
- Vue contact form without a backend: the overview, with a plain HTML fallback.
- Vue guide: the same component, and the Nuxt version.
- Prompts for AI builders: the same prompt for other tools.
- Pricing: free for 250 submissions a month, paid plans from €5.