Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@formstork/js

JavaScript SDK for Formstork. Your forms, delivered.

Framework-free. Turn any HTML form into a working contact form, no server, no backend code.

npm install @formstork/js

Wire up a form

import { formstork } from "@formstork/js";

const form = document.querySelector("#contact");
formstork(form, {
  accessKey: "YOUR_ACCESS_KEY", // get one at https://app.formstork.com
  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 that removes the handler.

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.",
});

MIT · formstork.com

About

Formstork JavaScript SDK. Your forms, delivered.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages