Runtimes

srvkit is built on srvx, which provides a universal serve() abstraction over the Web API Request/Response interface. Your server handler works across runtimes without changes — srvkit adapts the module resolution and build output to match each target.

The runtime option sets the bundler's resolve conditions to match the target environment, ensuring the correct conditional exports from your dependencies are used. For the workerd runtime, the bundler target is also set to webworker instead of node.

Setting the runtime

Use the runtime option in your plugin configuration:

Vite
Rsbuild
vite.config.ts
import { defineConfig } from "vite";
import { srvkit } from "@srvkit/vite/plugin";

export default defineConfig({
    plugins: [
        srvkit({
            runtime: "node",
        }),
    ],
});

The default runtime is "node".

Supported runtimes

node

The default. Produces output meant to run with Node.js.

node ./dist/index.js

The build resolves Node.js builtins and keeps them external. When using bundle: "standalone", only Node.js builtins remain as external imports.

deno

Produce output for the Deno runtime. Module resolution conditions are set for Deno compatibility.

deno ./dist/index.js

bun

Produce output for the Bun runtime. Module resolution conditions are set for Bun compatibility.

bun ./dist/index.js

workerd

Produce output for Cloudflare Workers. Use with build.target: "handler" to generate a handler that the Workers runtime can invoke directly.

srvkit({
    runtime: "workerd",
    build: {
        target: "handler",
    },
});

The output exports a default fetch handler compatible with the Cloudflare Workers export default convention.