Logo

Worker Runtimes

Worker Runtimes are the new standard for writing HTTP servers in JavaScript.

Learn More Contribute

Worker Runtimes are the new standard for writing HTTP servers in JavaScript.

Origin

Worker Runtimes are an adaptation of the Service Workers API, which is a browser standard for offline web applications. To give web developers more freedom over offline experiences, the specification includes a (minimal) HTTP server. Since it was published, other vendors have implemented this API for servers that run in the cloud — or on the edge in the case of Cloudflare Workers.

Typically, they also implement other browser APIs such as Fetch, Streams, and Web Cryptography, making their global scope similar to that of a Service Worker. We call them Worker Runtimes or Worker Contexts.

To see which vendors and APIs are available, check out the State of Worker Runtimes below.

self.addEventListener('fetch', event => {
  event.respondWith(new Response('Hello World', {
    headers: { 'Content-Type': 'text/plain' }
  }));
})

Example of a minimal HTTP server using Service Workers API

Since originally writing this, both Deno and Cloudflare Workers have dropped support for the pattern shown above. While the Request and Response classes remain, the global fetch event and respondWith method do not. The reasons are difficult to ascertain, but it seems it was deemed too confusing for beginners.

State of Worker Runtimes

There are currently two production quality Worker Runtimes. There are multiple offline, testing, and development implementations. Cloudflare Workers was the first, and is the most battle-tested Worker Environment. Deno Deploy is a close second.

Cloudflare Workers Deno Deploy Miniflare



 Service WorkersCloudflare WorkersDeno CLIDeno DeployFastly Compute@EdgeMiniflarecfworker/devcloudflare-
worker-local
DomainClientEdgeServerEdgeEdgeTesting, DevTesting, DevTesting, Dev
Open Sourceℹ️
1.0

Legend

Supported
ℹ️
Partial support / attention required
🔜
Implementation in progress
👨‍💻
Supported via 3rd party library / polyfill
Support to be determined
🚫
Not supported
🔙
Backwards compatibility only
💀
Support dropped

Browser APIs

The center piece of any Worker Environment is an implementation of the global fetch event. Implementations of other browser APIs are necessary for bridging the gap between different worker runtimes.

 Service WorkersCloudflare WorkersDeno CLIDeno DeployFastly C@EMiniflarecfworker/devcloudflare-
worker-local
fetch event🔙👨‍💻🚫
URL APIℹ️
Fetch API
Abort Controller/Signal👨‍💻👨‍💻
URL Pattern APIℹ️🚫👨‍💻👨‍💻
Encoding API
Streams APIℹ️ℹ️ℹ️ℹ️🚫
Encoding Streamsℹ️🚫🚫🚫🚫🚫
Compression Streamsℹ️🚫🚫🚫
Web Cryptography APIℹ️
crypto.randomUUID()ℹ️🚫
Cache APIℹ️🔜🚫ℹ️ℹ️
WebSocket APIℹ️🚫ℹ️🚫🚫
Web Socket Stream🔜🔜🚫🚫🚫
Location API👨‍💻🚫👨‍💻👨‍💻👨‍💻
consoleℹ️
queueMicrotaskℹ️
structuredCloneℹ️
navigator.userAgent🚫
Response.jsonℹ️🚫
EventTarget and Event
Web Workers API🚫🚫🚫🚫
Message Channel🚫🚫🚫🚫🚫
Broadcast Channelℹ️🚫🔜ℹ️🚫🚫🚫🚫
IndexedDB🚫🚫🚫🚫🚫
Performance API🚫🚫🚫

Working Drafts

The APIs below are either abandoned or do not have buy-in from major browser vendors. However, they can still be reasonable targets for 3rd party libraries, such as KV stores or cookie middleware.

 Service WorkersCloudflare WorkersDeno CLIDeno DeployFastly C@EMiniflarecfworker/devcloudflare-
worker-local
KV Storage API👨‍💻👨‍💻👨‍💻👨‍💻🚫👨‍💻👨‍💻👨‍💻
Cookie Store APIℹ️👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻👨‍💻

Non-Standard APIs

These are useful APIs provided by one or more Worker Environment that aren’t on any standards track (including abandoned).

 Service WorkersCloudflare WorkersDeno CLIDeno DeployFastly C@EMiniflarecfworker/devcloudflare-
worker-local
scheduled event🚫🚫🚫🚫🚫🚫
HTMLRewriter👨‍💻👨‍💻👨‍💻🚫ℹ️👨‍💻
KV🚫🚫🚫🚫ℹ️
Durable Objects🚫🚫🚫🚫🚫🚫
crypto.DigestStream🚫🚫🚫🚫🚫🚫
Ed25519 via WebCrypto🚫🚫🚫🚫🚫🚫

General Capabilities, Non-Standard

These are some general capabilities provided by one or more Worker Environment that share similarities but aren’t tied to a specific API.

 Service WorkersCloudflare WorkersDeno CLIDeno DeployFastly C@EMiniflarecfworker/devcloudflare-
worker-local
File system access🚫🚫ℹ️🚫🚫🚫🚫
Connect TCP🚫🔜🚫🔜🚫🚫
Connect UDP🚫🔜🔜🔜🚫🔜🚫🚫
WebSockets (Server)🚫🚫🚫🚫

Backend for Frontend

Worker Runtimes fulfill the original promise of NodeJS: To use one language and share code between client and server. In practice, this never came to be. Instead the APIs of node and browsers have diverged1. Worker Runtimes are bringing them back together.

This is good news for Frontend Developers in particular: The knowledge acquired for building (offline) web applications can now be applied to writing HTTP servers — and so can the tools:

Worker Tools Logo

Tools

No HTTP Server is complete without a web framework for common tasks such as routing, sessions, authentication, and more.

Worker Tools is a collection of tools and libraries for writing web servers, built specifically for Worker Runtimes. They can be used independently, or as a complete framework via Shed.

Contributing

Are you aware of any other Worker Runtimes available or in development? Did you find any inaccuracies in the tables above? Open a PR in the workers.js.org repository!


  1. Node and the browser have diverged due to a lack of browser APIs for many crucial components, including HTTP, streams, file access, and more more. A lot has changed since then. Standards have been written for all of these and more, often informed by the experience of using the node-equivalent. ↩︎