← Blog

Handle form submissions in SvelteKit without a backend route

Collect SvelteKit form submissions with a hosted endpoint — no server action, no database, progressive enhancement optional.

To handle form submissions in SvelteKit without a server action or a database, point a native <form> at a hosted, domain-locked endpoint. The browser posts the email cross-origin, the endpoint stores it against your campaign, and you have no +page.server.ts action to maintain.

Native POST, no action

A SvelteKit form action is the right tool when you own the backend. For a signup or contact form you do not — so skip it and post straight to the endpoint with your public campaign id (pub_...).

SvelteKit form (native POST)
<!-- src/routes/+page.svelte -->
<!-- Posts cross-origin to Simple Signups; no server action needed. -->
<form method="POST" action="https://simple-signups.com/api/subscribe">
<input type="hidden" name="campaignId" value="pub_your_campaign_id" />
<input type="email" name="email" required placeholder="you@example.com" />
<input type="text" name="hp" tabindex="-1" autocomplete="off"
style="position:absolute;left:-9999px" aria-hidden="true" />
<button type="submit">Subscribe</button>
</form>

When a SvelteKit action is worth it

Use a SvelteKit form action when your server owns the workflow — for example, when you must combine the submit with authenticated app state. For a public signup or contact form, that extra server hop usually adds complexity without adding value.

Progressive enhancement

The plain form works with JavaScript disabled. If you want inline success/error UX, keep the same endpoint and add use:enhance or a small fetch submit on top. Remember to allow-list each hostname you embed from — see the quickstart.

Related