sveltekit-remote-functions

SvelteKit remote functions guidance. Use for command(), query(), form() patterns in .remote.ts files.

⭐6stars🔀0forks📁View on GitHub🕐Updated Dec 30, 2025

When & Why to Use This Skill

This Claude skill provides expert guidance for implementing SvelteKit remote functions, focusing on command, query, and form patterns. It streamlines the development of type-safe server-side logic within .remote.ts files, ensuring seamless client-server communication with integrated schema validation and JSON-serializable data handling.

Use Cases

  • Case 1: Implementing one-time server actions, such as deleting a user or updating a database record, using the command() pattern.
  • Case 2: Creating efficient, repeatable data-fetching logic for client-side components using the query() pattern to ensure consistent state.
  • Case 3: Handling complex form submissions with robust server-side validation using StandardSchemaV1 (Valibot/Zod) via the form() pattern.
  • Case 4: Accessing server-side context, including cookies and headers, within remote functions using the getRequestEvent() utility.
namesveltekit-remote-functions
# IMPORTANTKeep description on ONE line for Claude Code compatibility
descriptionSvelteKit remote functions guidance. Use for command(), query(), form() patterns in .remote.ts files.

SvelteKit Remote Functions

Quick Start

File naming: *.remote.ts for remote function files

Which function? One-time action → command() | Repeated reads → query() | Forms → form()

Example

// actions.remote.ts
import { command } from '$app/server';
import * as v from 'valibot';

export const delete_user = command(
	v.object({ id: v.string() }),
	async ({ id }) => {
		await db.users.delete(id);
		return { success: true };
	},
);

// Call from client: await delete_user({ id: '123' });

Reference Files

Notes

  • Remote functions execute on server when called from browser
  • Args/returns must be JSON-serializable
  • Schema validation via StandardSchemaV1 (Valibot/Zod)
  • getRequestEvent() available for cookies/headers access
  • Last verified: 2025-01-13