Formstorkdocs
PricingENTRDashboard

React

Use the official hook, @formstork/react, to wire up a form in one line.

npm install @formstork/react
import { useFormstork } from "@formstork/react";

export function ContactForm() {
  const { submit, isSubmitting, isSuccess, message } = useFormstork({
    accessKey: "YOUR_ACCESS_KEY",
  });

  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>
  );
}

The hook collects the form fields automatically and posts them for you. It returns state, message, and the flags isSubmitting / isSuccess / isError.

Without the hook

If you’d rather not add a dependency, post the form directly:

async function onSubmit(e: React.FormEvent<HTMLFormElement>) {
  e.preventDefault();
  const form = new FormData(e.currentTarget);
  await fetch("https://api.formstork.com/submit", {
    method: "POST",
    body: form,
    headers: { Accept: "application/json" },
  });
}