Connect Vue forms to email
Receive messages from a Vue contact component with a native form submission. The input names become fields in GlueForms, so this example needs no reactive state or submit handler.
Connect the form
-
In GlueForms, open Forms, choose your form and copy its receiving URL. Select it above, or replace
YOUR_FORM_URLin the example. -
Create
src/components/ContactForm.vuewith the template below.
<template>
<form action="YOUR_FORM_URL" method="POST">
<label>
Name
<input name="name" autocomplete="name">
</label>
<label>
Email
<input name="email" type="email" autocomplete="email" required>
</label>
<label>
Message
<textarea name="message" rows="4" required></textarea>
</label>
<button type="submit">Send message</button>
</form>
</template>- Import the component into the page where you want the form. In a Vue/Vite project, this
src/App.vueexample renders it.
<script setup>
import ContactForm from './components/ContactForm.vue';
</script>
<template>
<ContactForm />
</template>Keep the native action and method attributes. Adding @submit.prevent without an alternative submission handler stops this form from sending.
A native submission opens the GlueForms JSON receipt in the browser. Use JavaScript to show a confirmation on your own page.
Publish the page and submit a message. Open it in GlueForms to check the field names, saved content and email notification.
Official documentation: Vue Single-File Components, Vue event modifiers.