@formstork/vue
v0.1.1
Published
Vue composable for Formstork. Your forms, delivered.
Maintainers
Readme
@formstork/vue
Vue composable for Formstork. Your forms, delivered.
Turn any form into a working contact form with one composable. No server, no backend code.
npm install @formstork/vueUsage
<script setup>
import { useFormstork } from "@formstork/vue";
const { submit, isSubmitting, isSuccess, message } = useFormstork({
accessKey: "YOUR_ACCESS_KEY", // get one at https://app.formstork.com
});
</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>API
useFormstork({ accessKey, endpoint?, onSuccess?, onError? }) returns refs:
| Field | Type | Description |
|---|---|---|
| submit | (e) => Promise | submit handler, collects form fields automatically |
| send | (payload) => Promise | Programmatic submit |
| reset | () => void | Reset back to idle |
| state | Ref<"idle" \| "submitting" \| "success" \| "error"> | Current state |
| message | Ref<string \| null> | Server or error message |
| isSubmitting / isSuccess / isError | ComputedRef<boolean> | Convenience flags |
Also exports submitToFormstork(accessKey, payload, endpoint?) for non-Vue use.
MIT · formstork.com
