Formstorkdocs
PricingENTRDashboard

Svelte

Use the official store, @formstork/svelte, to wire up a form in one line. Works with Svelte 4 and 5.

npm install @formstork/svelte
<script>
  import { createFormstork } from "@formstork/svelte";

  const { submit, isSubmitting, isSuccess, message } = createFormstork({
    accessKey: "YOUR_ACCESS_KEY",
  });
</script>

{#if $isSuccess}
  <p>Thanks, {$message}</p>
{:else}
  <form on: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>
{/if}

The store collects the form fields automatically and posts them for you. It returns Svelte stores: state, message, and the flags isSubmitting / isSuccess / isError (use them with the $ prefix).

Without the store

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

async function onSubmit(e) {
  e.preventDefault();
  await fetch("https://api.formstork.com/submit", {
    method: "POST",
    body: new FormData(e.target),
    headers: { Accept: "application/json" },
  });
}