Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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/vue

Usage

<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

About

Vue composable for Formstork. Your forms, delivered.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages