Experimental Vite plugin for calling server-side functions in SvelteKit as if they were local client-side hooks.
This project is experimental and not production-ready. Use it at your own risk.
We currently have no plans to publish it as a stable package, but contributions and feedback are welcome.
This experimental system lets you:
src/lib/server/*.ts
isPending
, data
, error
(via auto-generated code, not a public API)The system scans and rewrites imports from src/lib/server/**/*
in your Svelte files.
For example:
import { getUser } from "$lib/server/get-user";
// This call is automatically transformed by the plugin to use an internal hook for RPC.
const { data, error, isPending } = getUser("123");
Note: The internal hook (
useServerFunction
) is not meant to be used directly by developers. All transformation is handled automatically.
When you run the dev server or build your project, the system now generates:
src/lib/.svelte-server-functions-map.ts
These files contain metadata about all exported server functions, including their IDs, file paths, and export names. The system keeps them up to date with any file changes, additions, or deletions in your server function files.
src/lib/.svelte-server-functions-map.ts
virtual:server-functions/manifest
)// .svelte-server-functions-map.ts
import * as mod0 from '$lib/server/get-user';
export const modules = {
"$lib/server/get-user": mod0,
};
// virtual:server-functions/manifest
export const manifest = {
"df4e9a87": {
id: "df4e9a87",
filePath: "$lib/server/get-user",
exportName: "getUser"
}
};
You do not need to manually update or maintain these files; everything is handled automatically by the system.