Create SvelteKit components using Remote Functions for type-safe client-server communication. Use when building components that need to fetch data, submit forms, or execute server commands. Remote Functions work at the component level, not page level.
Remote Functions are a SvelteKit feature for type-safe client-server communication. They run on the server but can be called from any component.
Add to svelte.config.js:
const config = {
kit: {
experimental: {
remoteFunctions: true
}
},
compilerOptions: {
experimental: {
async: true // Optional: enables await in components
}
}
}
Put as little as possible in +page.svelte, as much as possible in data.remote.ts.
Build final data structures server-side. Pages should be pure renderers that map types to components.
See REMOTE-FIRST.md for patterns and examples.
| Type | Purpose | Reference |
| ----------- | --------------------------------------------------------------- | ------------------------ |
| query | Read dynamic data | QUERY.md |
| form | Handle form submissions | FORM.md |
| command | Programmatic mutations, avoid if possible. Always prefer form | COMMAND.md |
| prerender | Static data at build time | (not covered) |
For refreshing queries after mutations, see SINGLE-FLIGHT.md.
For starter code blocks, see TEMPLATES.md.
Use Remote Functions when:
Use Load Functions when:
npx skills add svelte-society/using-remote-functions下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer