
Sveltekit Remote Functions
This covers SvelteKit's experimental remote functions feature, which lets you write server-only functions in .remote.ts files and call them directly from components as if they were local. You get four primitives: query() for reads, command() for mutations, form() for progressive enhancement, and prerender() for build-time data. The skill includes validation patterns with valibot or zod, batching to avoid n+1 queries, and a requested() mechanism for opt-in cache invalidation. It's current as of SvelteKit 2.58 and handles the quirks around serialization limits and refresh semantics. Useful if you're tired of writing both API routes and fetch calls for simple server interactions.
- skills.sh installs
- 430
- GitHub stars
- 95
- last updated
- Aug 21, 2026
Install
$ npx -y skills add spences10/svelte-skills-kit --skill sveltekit-remote-functions --agent claude-codeInstalls into .claude/skills of the current project.
Files
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';
Sponsors
Details
- Repository
- github.com/spences10/svelte-skills-kit
- Category
- Frontend Development
- First seen
- Jun 3, 2026