A Form component for SvelteKit that enhances the native form element, preventing full page reloads on form submission if JavaScript is enabled.
- Works without JavaScript, its just a form!
- Prevents full page reloads on submission when JavaScript is enabled.
- Automatically refetches the page data after submission.
- Allows for optimisic UI updates.
npm install sveltekit-form
Simply replace any usage of <form>
with <Form>
<script lang="ts">
import { Form } from 'sveltekit-form';
</script>
<Form method="post" let:form>
<input name="username" />
<input type="password" name="password" />
<button disabled={form.transition.state !== 'idle'}> Login </button>
<button formaction="/forgot-password"> Forgot Password </button>
</Form>
This project is used in production at Aircast.