一键导入
sveltekit-remote-functions
Implement SvelteKit remote functions. Use for query(), query.live(), form(), command(), and prerender() patterns in .remote.ts files.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Implement SvelteKit remote functions. Use for query(), query.live(), form(), command(), and prerender() patterns in .remote.ts files.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Coordinate parallel agent work. Use when decomposing complex tasks, running review/implementation in parallel, managing task lists, or choosing shared vs isolated workspaces.
Svelte deployment guidance. Use for adapters, Vite config, pnpm setup, library authoring, PWA, or production builds.
SvelteKit data flow guidance. Use when working with load functions, form actions, server/client boundaries, serialization, or invalidation.
SvelteKit structure guidance. Use for routing, layouts, error handling, SSR, or svelte:boundary. Covers file naming, nested layouts, error boundaries, pending UI, and hydration.
Svelte 5 core best practices. Use when creating, editing, or reviewing .svelte, .svelte.ts, or .svelte.js files. Routes to deeper Svelte skills.
Build Svelte LayerChart components. Use for tooltip snippets, Chart context access, gradients, highlights, axes, and Svelte 5 snippet patterns.
| name | sveltekit-remote-functions |
| description | Implement SvelteKit remote functions. Use for query(), query.live(), form(), command(), and prerender() patterns in .remote.ts files. |
| metadata | {"last_updated":"2026-06-08","verified_against":"Svelte 5/Kit docs, sveltejs/svelte#18282, query.live examples, and SvelteKit Vite-plugin config post"} |
Remote functions are experimental in SvelteKit 2.58. Prefer enabling them in vite.config.ts via the SvelteKit Vite plugin:
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [
sveltekit({
experimental: { remoteFunctions: true },
compilerOptions: { experimental: { async: true } } // only for await in components
})
]
});
File naming: export remote functions from *.remote.ts or *.remote.js.
Remote files can live anywhere under src except src/lib/server.
Which function?
query()query.live()form()command()prerender()// posts.remote.ts
import { command, query, requested } from "$app/server";
import * as v from "valibot";
export const getPosts = query(
v.object({ tag: v.optional(v.string()) }),
async (filter) => {
return db.posts.find(filter);
},
);
export const createPost = command(
v.object({ title: v.string() }),
async (data) => {
await db.posts.create(data);
for (const { query } of requested(getPosts, 5)) {
void query.refresh();
}
},
);
Client:
<script lang="ts">
import { createPost, getPosts } from './posts.remote';
const posts = $derived(await getPosts({ tag: 'svelte' }));
</script>
<button onclick={() => createPost({ title: 'New' }).updates(getPosts)}>
Create
</button>
svelte.config.js still works in Kit 2, but Kit 3 will read Kit config from the Vite plugin instead.devalue; avoid functions, class instances, symbols, circular refs, and RegExp.valibot, zod, arktype, etc.) or use .unchecked/'unchecked' deliberately.query.batch() batches calls from the same macrotask to solve n+1 reads.query.live() returns an async iterable; SSR uses the first yield, clients stay connected while rendered.Promise.withResolvers()/pubsub).connected and reconnect(), but no refresh(); .run() returns Promise<AsyncGenerator<T>>.Cache-Control: no-store streams.form().enhance() submit() returns true when submission is valid/successful and false for validation failures..updates() is client-requested; server handlers must opt in with requested(queryFn, limit).requested() now yields { arg, query }; call query.refresh()/query.set(...) on the bound instance.limit is required for requested() to cap client-controlled refresh requests.void query.refresh()/void query.set(value); SvelteKit awaits and serializes the updates.void live_query.reconnect().form() over command() where progressive enhancement matters.prerender() for data that changes at most once per deployment.