Skip to content
Dashboard

Inside Workflow DevKit: How framework integrations work

Adrian LamSoftware Engineer

Link to headingThe pattern behind every WDK integration

Link to headingBuild-time: Generating workflow handlers

Link to headingRuntime: Exposing handlers as endpoints

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

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()
]
};

Link to headingBuild-time

Link to headingRuntime

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

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

Link to headingScaling the pattern across frameworks

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

Link to headingHTTP server frameworks (Express, Hono)

Link to headingOpening up workflows to every framework

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