React hook for Formstork. Your forms, delivered.
Turn any HTML form into a working contact form with one hook. No server, no backend code.
npm install @formstork/reactimport { useFormstork } from "@formstork/react";
export function ContactForm() {
const { submit, isSubmitting, isSuccess, message } = useFormstork({
accessKey: "YOUR_ACCESS_KEY", // get one at https://app.formstork.com
});
if (isSuccess) return <p>Thanks, {message}</p>;
return (
<form onSubmit={submit}>
<input type="text" name="name" required />
<input type="email" name="email" required />
<textarea name="message" required />
<button disabled={isSubmitting}>
{isSubmitting ? "Sending…" : "Send"}
</button>
</form>
);
}useFormstork({ accessKey, endpoint?, onSuccess?, onError? }) returns:
| Field | Type | Description |
|---|---|---|
submit |
(e) => Promise |
onSubmit handler, collects form fields automatically |
send |
(payload) => Promise |
Programmatic submit |
reset |
() => void |
Reset back to idle |
state |
"idle" | "submitting" | "success" | "error" |
Current state |
message |
string | null |
Server or error message |
isSubmitting / isSuccess / isError |
boolean |
Convenience flags |
Also exports submitToFormstork(accessKey, payload, endpoint?) for non-React use.
MIT · formstork.com