Remote Functions (experimental)

SvelteKit’s remote functions are the newest data primitive: server functions you call directly from components, with fine-grained queries and mutations instead of load-function waterfall plumbing. Still experimental, but they map closely onto how Next.js users think about server actions.

Enable

// vite.config.js
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vite';

export default defineConfig({
    plugins: [
        sveltekit({
            experimental: {
                remoteFunctions: true,
            },
            compilerOptions: {
                experimental: {
                    async: true,
                },
            },
        }),
    ],
});

The primitives

/// file: src/routes/data.remote.js
import { query, form, prerender } from '$app/server';

// query: cached, callable from client or server
export const getPosts = query(async () => {
    return db.sql`SELECT title, slug FROM post ORDER BY published_at DESC`;
});

// prerender: runs at build time, result cached on a CDN
export const getTopics = prerender(async () => {
    return db.sql`SELECT id, name FROM topic`;
});

Mutations use form, and can drive targeted refreshes instead of invalidating everything:

export const createPost = form(async (data) => {
    await db.insertPost(data);
    void getPosts().refresh();
});

Why it matters

Before remote functions, SvelteKit data flow meant +page.server.js load functions and form actions routed through file conventions. Remote functions let components import and call server logic directly, with query() handling deduplication and caching. For a content site backed by an API, prerender + query covers the build-time/TTL split without extra libraries.

Gotcha: this is an experimental opt-in behind compiler flags. API surface may change in minor releases; pin versions and read the changelog before adopting in production.

Status (2026-10)

Current line: Svelte 5.57, SvelteKit 3.0. Remote functions remain experimental but are documented in core concepts and actively developed.