Nuxt
Nuxt 3 runs on Vue, so the @formstork/vue composable drops straight into any <script setup> component. You get a working contact form in one file, with no server code to maintain.
Install
npm install @formstork/vue
Add the component
Create a ContactForm.vue file under components/. Nuxt auto-imports it, so you can drop <ContactForm /> into any page.
<script setup>
import { useFormstork } from "@formstork/vue";
const { submit, isSubmitting, isSuccess, message } = useFormstork({
accessKey: "YOUR_ACCESS_KEY",
});
</script>
<template>
<p v-if="isSuccess">Thanks, {{ message }}</p>
<form v-else @submit="submit">
<input type="text" name="name" required />
<input type="email" name="email" required />
<textarea name="message" required></textarea>
<button :disabled="isSubmitting">
{{ isSubmitting ? "Sending..." : "Send" }}
</button>
</form>
</template>
The composable reads the form fields, posts them for you, and exposes reactive refs: isSubmitting, isSuccess, and message.
Step by step
- Grab a free access key from the Formstork dashboard at app.formstork.com.
- Install the composable:
npm install @formstork/vue. - Add the
ContactForm.vuefile above undercomponents/, then swapYOUR_ACCESS_KEYfor your key. - Place
<ContactForm />in a page such aspages/contact.vue. - Run
npm run dev, send a test message, and watch it land in your dashboard.
The free plan covers 250 submissions a month.
Without the composable
If you would rather not add a dependency, post the form directly with fetch. This works in any Nuxt component with no imports:
<script setup>
async function onSubmit(e) {
e.preventDefault();
await fetch("https://api.formstork.com/submit", {
method: "POST",
body: new FormData(e.target),
headers: { Accept: "application/json" },
});
}
</script>
<template>
<form @submit="onSubmit">
<input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />
<input type="email" name="email" required />
<textarea name="message" required></textarea>
<button>Send</button>
</form>
</template>