JavaScript
Use the framework-free SDK, @formstork/js, in any site or app, no framework required.
npm install @formstork/js
Wire up a form
import { formstork } from "@formstork/js";
const form = document.querySelector("#contact");
formstork(form, {
accessKey: "YOUR_ACCESS_KEY",
onSuccess: () => alert("Thanks, your message was sent."),
onError: (message) => alert(message),
});
formstork(form, options) attaches a submit handler that collects the form fields and posts them. It returns a cleanup function. While submitting it sets data-formstork-state on the form to submitting, success, or error, so you can style states in CSS.
Programmatic submit
import { submitToFormstork } from "@formstork/js";
const res = await submitToFormstork("YOUR_ACCESS_KEY", {
email: "ada@example.com",
message: "Loved the demo.",
});
No build step
Prefer plain HTML with no JavaScript at all? See the HTML guide, point your form’s action at the endpoint and you are done.