svelte5-best-practices

Svelte 5 Best Practices

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "svelte5-best-practices" with this command: npx skills add ejirocodes/agent-skills/ejirocodes-agent-skills-svelte5-best-practices

Svelte 5 Best Practices

Quick Reference

Topic When to Use Reference

Runes $state, $derived, $effect, $props, $bindable, $inspect runes.md

Snippets Replacing slots, {#snippet}, {@render} snippets.md

Events onclick handlers, callback props, context API events.md

TypeScript Props typing, generic components typescript.md

Migration Svelte 4 to 5, stores to runes migration.md

SvelteKit Load functions, form actions, SSR, page typing sveltekit.md

Performance Universal reactivity, avoiding over-reactivity, streaming performance.md

Essential Patterns

Reactive State

<script> let count = $state(0); // Reactive state let doubled = $derived(count * 2); // Computed value </script>

Component Props

<script> let { name, count = 0 } = $props(); let { value = $bindable() } = $props(); // Two-way binding </script>

Snippets (replacing slots)

<script> let { children, header } = $props(); </script>

{@render header?.()} {@render children()}

Event Handlers

<!-- Svelte 5: use onclick, not on:click --> <button onclick={() => count++}>Click</button>

Callback Props (replacing createEventDispatcher)

<script> let { onclick } = $props(); </script>

<button onclick={() => onclick?.({ data })}>Click</button>

Common Mistakes

  • Using let without $state

  • Variables are not reactive without $state()

  • Using $effect for derived values - Use $derived instead

  • Using on:click syntax - Use onclick in Svelte 5

  • Using createEventDispatcher

  • Use callback props instead

  • Using <slot>

  • Use snippets with {@render}

  • Forgetting $bindable()

  • Required for bind: to work

  • Setting module-level state in SSR - Causes cross-request leaks

  • Sequential awaits in load functions - Use Promise.all for parallel requests

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

AgentBnB

Find, hire, and serve specialist AI agents on the AgentBnB network from OpenClaw or Claude Code. Use when you need multi-agent delegation, provider discovery...

Registry SourceRecently Updated
2191Profile unavailable
Coding

Nutrient Document Processing (Universal Agent Skill)

Universal (non-OpenClaw) Nutrient DWS document-processing skill for Agent Skills-compatible products. Best for Claude Code, Codex CLI, Gemini CLI, Cursor, Wi...

Registry SourceRecently Updated
6210Profile unavailable
Coding

vercel-react-best-practices

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

Repository Source
361.8K25.9Kvercel
Coding

developing-genkit-js

No summary provided by upstream source.

Repository SourceNeeds Review
35.8K-firebase