sveltekit-remote-functions

Execute typed remote functions in SvelteKit .remote.ts files.

6|Updated Jul 7, 2017
One-click install
npx skills add https://github.com/Seeker1911/dotfiles --skill sveltekit-remote-functions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: sveltekit-remote-functions
Source: https://github.com/Seeker1911/dotfiles/tree/main/agents/skills/sveltekit-remote-functions
Command: npx skills add https://github.com/Seeker1911/dotfiles --skill sveltekit-remote-functions

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Executing server-side logic directly from client components in SvelteKit often requires creating explicit API endpoints. Remote functions simplify this by providing a type-safe, RPC-like mechanism that handles serialization and validation automatically, saving you development time and reducing boilerplate.

Core Features & Use Cases

  • command() for Actions: Perform one-time server actions like creating, updating, or deleting data with automatic validation, ensuring data integrity.
  • query() for Reads: Fetch data from the server, with support for automatic batching to optimize network requests and improve performance.
  • form() for Progressive Forms: Integrate server-side form handling with client-side progressive enhancement, ensuring forms work robustly with or without JavaScript.
  • Use Case: When you need to perform a database operation (e.g., delete_user), fetch specific data (get_user), or handle a form submission (login_form) directly from a Svelte component without manually setting up a +server.ts API route, this Skill streamlines your workflow.

Quick Start

I need to create a remote function in SvelteKit to delete a user by ID. Show me how to use command() with Valibot validation for the user ID.

Frequently Asked Questions about sveltekit-remote-functions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I call server-side code directly from a SvelteKit client component without creating API routes?

Remote functions provide a type-safe RPC interface that executes server code from the client automatically. Use `command()` for one-time actions, `query()` for data fetches, or `form()` for progressive forms—all with built-in validation and serialization, eliminating manual endpoint boilerplate.

What validation does SvelteKit remote functions support for inputs and outputs?

Remote functions use StandardSchemaV1 validation to enforce JSON-serializable data types on both inputs and outputs. Validation runs server-side before execution, ensuring data integrity and automatically returning typed errors to the client for handling.

Can I use remote functions to handle form submissions with progressive enhancement in SvelteKit?

Yes, the `form()` remote function integrates server-side form handling with client-side progressive enhancement, ensuring forms work robustly with or without JavaScript enabled by binding directly to Svelte components.

How do remote functions access the SvelteKit request context like headers or session data?

Remote functions access request context via `getRequestEvent()`, which provides the full SvelteKit event object. This lets you read headers, session data, and other request metadata directly within your server-side function logic.

Do remote functions support batching to optimize repeated data fetches from the client?

Yes, the `query()` function includes automatic batching support to combine multiple data-fetch requests into a single network call, reducing overhead and improving performance for repeated reads.

What happens to server-side errors when they're sent back to the client in remote functions?

Server-side errors are serialized and returned to the client for replay and handling. This allows client code to catch, log, and respond to errors that occur during remote execution without losing error context.