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