Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
spences10 avatar

Sveltekit Remote Functions

  • 366 installs
  • 92 repo stars
  • Updated April 29, 2026
  • spences10/svelte-skills-kit

sveltekit-remote-functions is an agent skill that implements typed SvelteKit remote functions using command(), query(), and form() in *.remote.ts files so developers can call server logic from components without custom f

About

sveltekit-remote-functions is a Svelte-focused agent skill from spences10/svelte-skills-kit that documents SvelteKit's experimental remote function patterns for type-safe server calls. Install with `npx skills add spences10/svelte-skills-kit --skill sveltekit-remote-functions`. The skill specifies *.remote.ts naming, maps one-time actions to command(), repeated reads to query(), and forms to form(), with Valibot or Zod validation via StandardSchemaV1 and JSON-serializable arguments. It notes getRequestEvent() for cookies and headers, query().refresh() for no-flicker updates, and restrictions such as avoiding src/lib/server placement. Reach for sveltekit-remote-functions when building SvelteKit features that need server execution without maintaining parallel REST endpoints and client wrappers.

  • SvelteKit-native remote function pattern
  • Typed server calls from components
  • Less boilerplate than manual API routes
  • Covers forms and data mutations
  • Fits full-stack SvelteKit SaaS apps

Sveltekit Remote Functions by the numbers

  • 366 all-time installs (skills.sh)
  • +5 installs in the week ending Jul 27, 2026 (Skillselion tracking)
  • Ranked #681 of 2,245 Frontend Development skills by installs in the Skillselion catalog
  • Data as of Jul 31, 2026 (Skillselion catalog sync)
npx skills add https://github.com/spences10/svelte-skills-kit --skill sveltekit-remote-functions

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs366
repo stars92
Last updatedApril 29, 2026
Repositoryspences10/svelte-skills-kit

How do you call SvelteKit server logic from components?

Implement typed SvelteKit remote functions that call server logic from components without hand-rolling fetch routes and client API glue.

Who is it for?

SvelteKit developers adopting experimental remote functions who want typed server calls without duplicate API routes and fetch glue.

Skip if: Skip sveltekit-remote-functions when the project uses only classic +page.server.ts load functions and form actions without remoteFunctions enabled.

When should I use this skill?

A developer asks about SvelteKit command(), query(), form(), .remote.ts files, or type-safe client-to-server calls in SvelteKit.

What you get

*.remote.ts modules with command(), query(), and form() handlers, Valibot or Zod schemas, and client call patterns.

  • *.remote.ts handler module
  • schema-validated server functions
  • component call examples

By the numbers

  • Covers three remote function primitives: command(), query(), and form()
  • Ships inside spences10/svelte-skills-kit with nine companion Svelte skills

Files

SKILL.mdMarkdownGitHub ↗

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

<!-- PROGRESSIVE DISCLOSURE GUIDELINES:

  • Keep this file ~50 lines total (max ~150 lines)
  • Use 1-2 code blocks only (recommend 1)
  • Keep description <200 chars for Level 1 efficiency
  • Move detailed docs to references/ for Level 3 loading
  • This is Level 2 - quick reference ONLY, not a manual

LLM WORKFLOW (when editing this file): 1. Write/edit SKILL.md 2. Format (if formatter available) 3. Run: npx skills add . --list 4. If the skill is not discovered, check SKILL.md frontmatter formatting 5. Validate again to confirm -->

Related skills

How it compares

Choose sveltekit-remote-functions for experimental remoteFunctions; use sveltekit-data-flow skills when sticking to load functions and classic form actions.

FAQ

What file naming does sveltekit-remote-functions require?

sveltekit-remote-functions requires remote function modules to use the *.remote.ts suffix. Files can live anywhere under src except src/lib/server, and exported functions become type-safe client wrappers that invoke server endpoints automatically.

Which SvelteKit remote function type should I use?

sveltekit-remote-functions maps one-time mutations to command(), repeated reads to query(), and HTML form submissions to form(). Picking the wrong primitive leads to extra round trips or missing validation hooks the skill documents.

Frontend Developmentfrontendbackendintegrations

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.