Integrations
SvelteKit
Use Katman with SvelteKit API routes — catch-all endpoint with full type safety.
SvelteKit uses file-based API routes. Katman integrates via a catch-all +server.ts.
Setup
// src/routes/api/rpc/[...path]/+server.ts
import { } from "katman/sveltekit"
import { } from "$lib/server/rpc"
const = (, {
: "/api/rpc",
: () => ({
: getDB(),
: .locals.user,
}),
})
export const =
export const = Context from SvelteKit hooks
Use SvelteKit's handle hook to set event.locals, then access in the context factory:
// src/hooks.server.ts
export async function ({ , }) {
.locals.user = await getUser(.cookies.get("session"))
return ()
}// src/routes/api/rpc/[...path]/+server.ts
const = katmanSvelteKit(appRouter, {
: () => ({
: .locals.user,
}),
})What's next?
- Server — standalone
serve()as an alternative - Integrations — other available integrations