spences10 avatar

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

Installs 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

More from spences10/svelte-skills-kit

All 8
1webflow avatarcms-best-practiceswebflow/webflow-skillsExpert guidance on Webflow CMS architecture and best practices. Use when planning collections, setting up relationships, optimizing content structure, or troubl419skills.sh installs
2syncfusion avatarsyncfusion-blazor-licensesyncfusion/blazor-ui-components-skillsGenerate, register, secure, validate, and troubleshoot Syncfusion Blazor license keys across all Blazor project types403skills.sh installs
3syncfusion avatarsyncfusion-blazor-datamanagersyncfusion/blazor-ui-components-skillsImplements Syncfusion Blazor SfDataManager for data access, data binding, and adaptor configuration in Blazor Server, WebAssembly, and Web App. Used when bindin395skills.sh installs
4syncfusion avatarsyncfusion-blazor-accumulation-chartsyncfusion/blazor-ui-components-skillsImplement Syncfusion Blazor Accumulation Chart (SfAccumulationChart) for proportional data visualization. Use this when creating pie charts, doughnut charts, fu393skills.sh installs
5webflow avatarlink-checkerwebflow/webflow-skillsFind and fix broken or insecure links across an entire site, including CMS content, to improve SEO and user experience. Audits HTTP/HTTPS issues and validates a393skills.sh installs
6syncfusion avatarsyncfusion-blazor-barcodesyncfusion/blazor-ui-components-skillsBuild and troubleshoot barcode generation in Blazor using SfBarcodeGenerator, SfQRCodeGenerator, and SfDataMatrixGenerator. Trigger for 1D barcodes (Code39, Cod377skills.sh installs