Skip to content
Ver. 0.0.4
Personal Project 2026
View Project →

SvelteKit Effect Runtime

A runtime-only adapter that brings Effect-ts into the SvelteKit server surface.
EffectSvelte

sveltekit-effect-runtime lets SvelteKit endpoints, loads, actions, and hooks be written as Effect programs instead of plain async functions, giving SvelteKit apps access to Effect's structured concurrency, typed errors, dependency injection, and observability without forking the framework or adopting a custom server.

Approach

Stay out of the way. The adapter is a thin set of wrappers: wrapHandler, wrapServerLoad, wrapActions, wrapHandle, universalLoad, and friends; that each map directly onto an existing SvelteKit entry point. Failures from Effect.fail(...) propagate back to SvelteKit unchanged, so error(...), fail(...), and redirect(...) keep working exactly as the framework expects. One configureRuntime(...) call in hooks.server.ts wires in app-wide layers, plus optional requestLayer and loadLayer hooks for per-request and per-load services derived from the current event.

Stack

TypeScript · Effect v4 · SvelteKit · Bun

What makes it different

Most Effect integrations ask you to restructure your app around a managed runtime. This one inverts that: SvelteKit stays the host, and Effect slots in at each boundary where you actually want it. Request-scoped services like SvelteRequest, currentRequestEvent, and currentLoadEvent are exposed as first-class Effect services, so handlers compose cleanly without threading event through every call. Runtime-only by design: no build step, no Vite plugin, no codegen.

More Work

← All Work