Vue guide
Vue contact form, no backend needed
This Vue 3 component posts to Formcrate, which filters spam, emails you and stores each submission. It works in any Vite or static Nuxt build.
1Create a form and copy its key
Sign up with Google, create a form and enter the email address that should receive submissions. Copy the form key from the dashboard: it replaces
YOUR_FORM_KEYbelow. The free plan includes 500 submissions a month.2Add your form key
With Vite, variables prefixed
VITE_are available in the browser..envVITE_FORMCRATE_KEY=YOUR_FORM_KEY
3Create the component
Sending
Accept: application/jsonmakes Formcrate answer with JSON instead of redirecting, so you can show your own success message without leaving the page.src/components/ContactForm.vue<script setup> import { ref } from 'vue'; const endpoint = `https://www.formcrate.dev/api/submit/${import.meta.env.VITE_FORMCRATE_KEY}`; const status = ref('idle'); async function onSubmit(e) { status.value = 'sending'; const res = await fetch(endpoint, { method: 'POST', headers: { Accept: 'application/json' }, body: new FormData(e.target), }); status.value = res.ok ? 'sent' : 'error'; } </script> <template> <p v-if="status === 'sent'">Thanks! We'll be in touch.</p> <form v-else @submit.prevent="onSubmit"> <input type="text" name="name" placeholder="Name" required /> <input type="email" name="email" placeholder="Email" required /> <textarea name="message" placeholder="Message" required></textarea> <input type="text" name="_gotcha" style="display:none" tabindex="-1" autocomplete="off" /> <button type="submit" :disabled="status === 'sending'"> {{ status === 'sending' ? 'Sending…' : 'Send' }} </button> <p v-if="status === 'error'">Something went wrong. Please try again.</p> </form> </template>4Send a test submission
Fill in the form on your site and submit it. The message appears in your Formcrate inbox and arrives by email within a few seconds. Anything that looks like spam goes to the Spam tab instead and isn't emailed.
5Lock the form to your domain
Your key is visible in the page source, which is normal for form backends. In the form settings, add your domain under Domain lock so other websites can't post to your form from the browser.
Tips
- In Nuxt, read the key from
useRuntimeConfig().publicinstead ofimport.meta.env.
Get your Vue form working
Free for 500 submissions a month. Spam filtering, email alerts and an inbox included. No card required.