SvelteKit
SvelteKit works with the @formstork/svelte store inside any route component. The store wires up the submit handler, loading flag, and success state, so your form works with almost no code.
Install
npm install @formstork/svelte
Client-side form
The simplest setup lives entirely in a +page.svelte route.
<!-- src/routes/contact/+page.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 reads every named field, adds the hidden access_key, and posts to Formstork for you. Read the Svelte stores it returns with the $ prefix.
Server-side form action
Prefer to keep the request off the client? Post to the endpoint from a form action instead.
// src/routes/contact/+page.server.js
export const actions = {
default: async ({ request }) => {
const data = await request.formData();
data.append("access_key", "YOUR_ACCESS_KEY");
await fetch("https://api.formstork.com/submit", {
method: "POST",
body: data,
headers: { Accept: "application/json" },
});
return { success: true };
},
};
Pair it with a plain <form method="POST"> in your +page.svelte.
Step by step
- Sign up at app.formstork.com and copy your free access key from the dashboard.
- Run
npm install @formstork/svelte. - Create a route such as
src/routes/contact/+page.svelte. - Add the
<script>above and swapYOUR_ACCESS_KEYfor your real key. - Give every input a
name; those become the fields you receive. - Use
$isSubmittingfor the button state and$isSuccessfor the thank-you message. - For a server-side flow, add the
+page.server.jsaction and amethod="POST"form.
Submissions land in your dashboard. The free plan covers 250 a month.