svelte-runtime
Installation
SKILL.md
Svelte Runtime Reference (Svelte 5)
本技能覆盖 Svelte 5 的运行时 API,包括跨组件状态(Stores/Context)、生命周期、命令式 API、SSR 和测试。
When to use this skill
当用户需要跨组件共享状态、处理组件生命周期、使用 mount/render 等命令式 API、或编写 Vitest 组件测试时使用本技能。
Critical: Stores (svelte/store)
Store 是一种跨组件共享响应式状态的老方式(Svelte 5 推荐用 .svelte.js 中的 $state 对象替代)。
writable
import { writable } from 'svelte/store';
const count = writable(0);