Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@formstork/svelte

Svelte store for Formstork. Your forms, delivered.

Turn any form into a working contact form with one store. No server, no backend code. Works with Svelte 4 and 5.

npm install @formstork/svelte

Usage

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

  const { submit, isSubmitting, isSuccess, message } = createFormstork({
    accessKey: "YOUR_ACCESS_KEY", // get one at https://app.formstork.com
  });
</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}

API

createFormstork({ accessKey, endpoint?, onSuccess?, onError? }) returns stores:

Field Type Description
submit (e) => Promise submit handler, collects form fields automatically
send (payload) => Promise Programmatic submit
reset () => void Reset back to idle
state Writable<"idle" | "submitting" | "success" | "error"> Current state
message Writable<string | null> Server or error message
isSubmitting / isSuccess / isError Readable<boolean> Convenience flags

Also exports submitToFormstork(accessKey, payload, endpoint?) for non-Svelte use.

MIT · formstork.com

About

Svelte store for Formstork. Your forms, delivered.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages