Skip to content

Instantly share code, notes, and snippets.

@EBBozkurt
EBBozkurt / use-form.svelte.ts
Last active December 18, 2025 11:13
A lightweight, type-safe form validation solution for Svelte 5 using Zod schemas. Built with Svelte 5 runes ($state, $derived) for reactive form management without external dependencies like Felte or react-hook-form.
/**
* NOTE: This file uses .svelte.ts extension for three reasons:
* 1. Runes support: Enables use of $state, $derived, $effect
* 2. Type safety: Works like normal TypeScript with full type checking
* 3. Easy import: Can be imported without the .svelte extension
*
* Regular .ts files cannot use Svelte runes - they would throw "rune_outside_svelte" error.
* The .svelte.ts extension tells the Svelte compiler to process this file and enable runes.
*/