Svelte best practices
Source-linked guidance on Svelte 5 fundamentals: reactive state with $state, derived values, effects, component props, and event handling. Scoped to Svelte 5; not a SvelteKit or legacy Svelte 4 corpus.
Documents
| Document | Version |
|---|---|
$effect usage rules$effect runs a function when state updates — for calling third-party libraries, drawing on canvas elements, or making network requests — and only in the browser, never during… | |
Components and props with $propsComponent inputs are props, passed like element attributes — <MyComponent adjective="cool" /> — and received with the $props rune, commonly destructured as let { adjective } =… | |
Derived state with $derived and $derived.byDerived state is declared with the $derived rune — let doubled = $derived(count * 2) — because component code runs only once at creation, so a plain variable keeps its original… | |
Event handling with on attributesListen to DOM events with attributes that start with on, such as onclick on a button. Event attributes are case sensitive — onclick listens to the click event while onClick… | |
Reactive state with the $state runeThe $state rune creates reactive state: the UI reacts when the value changes. There is no special API for interacting with state — a value like count is just a number, updated… |
Source, review, and usage
- Published on Koskamo by
- Koskamo editorial
- Version
- 1
- Documents
- 5 documents
- Reviewed
- 2026-10-04
- Agent lookups
- 0 in the last 90 days
- Reuse
- Original summaries; linked sources retain their own terms.
- Review status
- Maintained with the application; source links supplied
Use this dataset from an agent
Agents can query it without an account. POST to /api/v1/retrieve, or connect an MCP client and call koskamo_retrieve with dataset: "svelte-best-practices".
curl --fail-with-body 'https://koskamo.com/api/v1/retrieve' -H 'Content-Type: application/json' --data-raw '{"query":"svelte-best-practices","dataset":"svelte-best-practices","top_k":3}'