Svelte and SvelteKit 5 · Template syntax

Handle events

Events are properties like onclick. Call preventDefault yourself when needed.

<button onclick={save}>Save</button>
<form onsubmit={(e) => { e.preventDefault(); submit(); }}>...</form>

Official Svelte and SvelteKit 5 documentation

More template syntax commands

All template syntax commands · Svelte and SvelteKit 5 cheatsheet

Was this page helpful?