The fetchlet/sveltekit adapter bundles a SvelteKit 3 server into a fetchlet
artifact (build/server.js, build/client/, and build/fetchlet.json).
See the
sveltekit-axum
and
sveltekit-axum-tauri
examples for complete setups.
Setup
// vite.config.ts
import { sveltekit } from "@sveltejs/kit/vite";
import fetchletAdapter from "fetchlet/sveltekit";
import { defineConfig } from "vite";
export default defineConfig({
plugins: [
sveltekit({
compilerOptions: {
experimental: {
async: false,
},
},
adapter: fetchletAdapter({
out: "build",
backend: "quickjs",
}),
}),
],
});backend, intl, and requirements follow the
build options. Build
with vite build and develop with fetchlet dev (full
rebuild mode).
Request context and bindings
| From Rust | In SvelteKit |
|---|---|
Context clientAddress |
getClientAddress() |
| Host bindings | platform.env |
waitUntil |
platform.context.waitUntil |
| String env bindings | env passed to server.init |
Type platform.env by declaring your keys on
fetchlet/bindings.
Assets
Pass assets: true to pack client/ into build/assets.flpk:
- Files under
_app/immutable/receive a 1-yearCache-Control: immutableheader. - Prerendered pages are served without
.htmlor a trailing slash, matching SvelteKit’s defaulttrailingSlash: "never". - Customize rules with
assets: { include, routes, cache, respond, entries }(Asset archive).
Rendering profiles
rendering |
Use |
|---|---|
"synchronous" (default) |
Standard synchronous Svelte rendering (no node:async_hooks needed); promises returned from load still stream |
"async" |
Svelte’s async rendering (compilerOptions.experimental.async) and remote functions (experimental.remoteFunctions) |
sveltekit({
compilerOptions: { experimental: { async: true } },
experimental: { remoteFunctions: true },
adapter: fetchletAdapter({ rendering: "async" }),
});"async" enables asyncContext: "serialized" so getRequestEvent() works
across await within a request. In a remote function, call getRequestEvent()
before the first await if multiple remote functions run concurrently during
one render.