sveltekit-remote-functions

SvelteKit Remote Functions

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 "sveltekit-remote-functions" with this command: npx skills add spences10/svelte-skills-kit/spences10-svelte-skills-kit-sveltekit-remote-functions

SvelteKit Remote Functions

Current Status

Remote functions are experimental in SvelteKit 2.58. Enable them in svelte.config.js :

export default { kit: { experimental: { remoteFunctions: true } }, compilerOptions: { experimental: { async: true } } // only for await in components };

Quick Start

File naming: export remote functions from *.remote.ts or *.remote.js . Remote files can live anywhere under src except src/lib/server .

Which function?

  • Dynamic reads → query()

  • Progressive forms → form()

  • Event-handler mutations → command()

  • Build-time/static reads → prerender()

Example

// 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>

Current Rules

  • Remote functions always run on the server, even when called from the browser.

  • Args/returns use devalue ; avoid functions, class instances, symbols, circular refs, and RegExp .

  • Validate exposed inputs with Standard Schema (valibot , zod , arktype , etc.) or use .unchecked /'unchecked' deliberately.

  • query.batch() batches calls from the same macrotask to solve n+1 reads.

  • 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.

  • Inside command/form handlers, use void query.refresh() /void query.set(value) ; SvelteKit awaits and serializes the updates.

  • Prefer form() over command() where progressive enhancement matters.

  • Use prerender() for data that changes at most once per deployment.

  • Last verified: SvelteKit 2.58.0, 2026-04-24

Reference Files

  • references/remote-functions.md - Current patterns, examples, and gotchas

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.

General

sveltekit-structure

No summary provided by upstream source.

Repository SourceNeeds Review
General

svelte-runes

No summary provided by upstream source.

Repository SourceNeeds Review
General

sveltekit-data-flow

No summary provided by upstream source.

Repository SourceNeeds Review
General

Secretary Memory Hook

秘书记忆系统核心 Hook — 会话压缩时自动触发摘要/偏好提取/上下文召回。基于 session:compact:before 和 session:compact:after 事件,实现功能3(会话摘要)、功能4(偏好提取)、功能8(跨会话召回)的自动化。

Registry SourceRecently Updated