MainSDK
Search⌘K
How-to

Run on Workers, Deno and Bun

Run the same MainSDK routes on Cloudflare Workers, Deno and Bun, know which interfaces each runtime lacks, and start from the edge reference.

Planned for 1.6

Status Status is where the work is: Planned (in a milestone, not started), Building (tickets in progress), Preview (usable, may change), then the stability it ships at.

Stability The promise an interface ships with.

  • Stable Follows semantic versioning; breaking changes need a new major, 12 months of overlap and a codemod.
  • Beta Usable in production; may change before it becomes stable.
  • Experimental May change or go away; needs an explicit opt-in in main.yaml.
Stability levels
Updated 2026-10-28

You will run one set of routes on three runtimes and see which parts a runtime can't run. It takes about 15 minutes.

You need

  • A MainSDK app. Start from apps/examples/edge-reference if you have none.

1. Keep routes as a Request in and a Response out

The reference's src/routes.ts takes the policy engine and email interface as arguments and returns a Response, so Hono mounts it on Workers and a test calls it directly. Nothing in it imports a Node module.

2. Declare the runtime

main.yaml
targets:
  edge:
    runtime: workerd

mainsdk check raises MAIN-PORT-0001 when you add disk, system or cluster to a workerd target. RUNTIME_GAPS lists every declared gap per runtime with its fix.

3. Run the checks the reference runs

.github/workflows/ci.yml runs mainsdk check and mainsdk assure --standard soc2 on every pull request.

Check that it works

  • The portable suite prints one JSON line on each runtime with the same test count.
  • policy.decide stays under 1 ms at p99 on Node, Bun and Deno. On Workers performance.now() only moves on I/O, so that budget is measured from outside.

Was this page helpful?

↑↓ moveEnter openEsc close

Not decided yet