Skip to content
Lazyform

Contact form for Nuxt

Add a contact form to a Nuxt site with $fetch and no server route. Works with nuxt generate and sends every message to email, Telegram or Slack.

Free plan: 250 submissions a month, forever.

Why a form backend for Nuxt

Nuxt can run server routes with Nitro, so you could build the form handling yourself. That still means picking an email provider, storing secrets, adding spam checks and keeping it all running. If you deploy with nuxt generate, there's no server at all.

Lazyform takes the whole job. The page posts the form with $fetch, and you decide what to show based on the answer.

A working contact form

Replace YOUR_ACCESS_KEY with your key from /login.

pages/contact.vue
<script setup lang="ts">
const sent = ref(false)
const sending = ref(false)
const errorMessage = ref('')

async function onSubmit(event: Event) {
  const form = event.target as HTMLFormElement
  sending.value = true
  errorMessage.value = ''

  try {
    await $fetch('https://lazyform-api.xvelopers.com/submit', {
      method: 'POST',
      headers: { Accept: 'application/json' },
      body: new FormData(form),
    })
    sent.value = true
  } catch (err: any) {
    errorMessage.value = err?.data?.error?.message ?? 'Something went wrong. Please try again.'
  } finally {
    sending.value = false
  }
}

useHead({ title: 'Contact' })
</script>

<template>
  <p v-if="sent">Thanks! Your message was sent.</p>
  <form v-else @submit.prevent="onSubmit">
    <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />
    <input name="name" placeholder="Name" required />
    <input name="email" type="email" placeholder="Email" required />
    <textarea name="message" placeholder="Message" required />
    <input type="checkbox" name="botcheck" class="hidden" style="display: none" />
    <button :disabled="sending">{{ sending ? 'Sending…' : 'Send' }}</button>
    <p v-if="errorMessage" role="alert">{{ errorMessage }}</p>
  </form>
</template>

ref, $fetch and useHead are auto-imported in Nuxt, so there are no imports to add.

Get submissions where you want them

Each submission is emailed to you. Turn on Telegram, Slack, Discord or WhatsApp alerts, or send submissions to Google Sheets, Notion, Airtable or a webhook. See all integrations.

Full guide

The Nuxt guide covers runtime config, a no-JavaScript fallback, file uploads and captcha.

Questions

Do I need a server route in the server folder?

No. The form posts from the browser straight to Lazyform, so you don't write anything in server/api. It also works with nuxt generate and fully static hosting.

Why does $fetch throw on errors?

$fetch throws for non-2xx responses. The example catches that and reads Lazyform's error message from the response data, so visitors see a clear reason.

Can I keep the access key in runtime config?

Yes. Put it in runtimeConfig.public and read it with useRuntimeConfig(). It has to be public because the browser sends it, and that's fine: the key can't read submissions.