Skip to content
Dashboard

Inside Workflow DevKit: How framework integrations work

Adrian LamSoftware Engineer

Copy link to headingThe pattern behind every WDK integration

Copy link to headingBuild-time: Generating workflow handlers

Copy link to headingRuntime: Exposing handlers as endpoints

Copy link to headingHow WDK's three transform modes work

Custom Workflow DevKit Framework Integrations

Create your own Workflow DevKit framework integrations following an in-depth guide.

Learn More

Copy link to headingA pattern in practice: SvelteKit

vite.config.ts
import { sveltekit } from "@sveltejs/kit/vite";
import { workflowPlugin } from "workflow/sveltekit";
export default {
plugins: [
sveltekit(),
workflowPlugin()
]
};

Copy link to headingBuild-time

Copy link to headingRuntime

Copy link to headingWhy framework request objects required conversion

+server.js
async function convertSvelteKitRequest(request) {
const options = {
method: request.method,
headers: new Headers(request.headers)
};
if (!['GET', 'HEAD'].includes(request.method)) {
options.body = await request.arrayBuffer();
};
return new Request(request.url, options);
};

This helper function is injected into each workflow handler file to be compatible with SvelteKit

Copy link to headingHot Module Replacement

packages/sveltekit/src/plugin.ts
async hotUpdate({ file, read }) {
const content = await read();
const useWorkflowPattern = /^\s*(['"])use workflow\1;?\s*$/m;
const useStepPattern = /^\s*(['"])use step\1;?\s*$/m;
if (!useWorkflowPattern.test(content) && !useStepPattern.test(content)) {
return; // Not a workflow file, let Vite handle normally
}
await enqueue(() => builder.build()); // Queue rebuild with esbuild: important if concurrent builds ever happen
};

A minimal example of Workflow DevKit's HMR in Vite-based frameworks

Copy link to headingScaling the pattern across frameworks

Copy link to headingFile-based routing frameworks (Next.js, SvelteKit, Nuxt)

Copy link to headingHTTP server frameworks (Express, Hono)

Copy link to headingOpening up workflows to every framework

Copy link to headingThe pattern holds

Start Building with Workflow DevKit

Use familiar JavaScript to build workflows that persist across deploys and crashes. No queues, schedulers, or extra infrastructure required.

Get Started

Ready to deploy?