Tech News
← Back to articles

Cap'n Web: a new RPC system for browsers and web servers

read original related products more articles

12 min read

Allow us to introduce Cap'n Web , an RPC protocol and implementation in pure TypeScript.

Cap'n Web is a spiritual sibling to Cap'n Proto , an RPC protocol I (Kenton) created a decade ago, but designed to play nice in the web stack. That means:

Like Cap'n Proto, it is an object-capability protocol. ("Cap'n" is short for "capabilities and".) We'll get into this more below, but it's incredibly powerful.

Unlike Cap'n Proto, Cap'n Web has no schemas . In fact, it has almost no boilerplate whatsoever. This means it works more like the JavaScript-native RPC system in Cloudflare Workers .

That said, it integrates nicely with TypeScript.

Also unlike Cap'n Proto, Cap'n Web's underlying serialization is human-readable. In fact, it's just JSON, with a little pre-/post-processing.

It works over HTTP, WebSocket, and postMessage() out-of-the-box, with the ability to extend it to other transports easily.

It works in all major browsers, Cloudflare Workers, Node.js, and other modern JavaScript runtimes.

The whole thing compresses (minify+gzip) to under 10 kB with no dependencies.

... continue reading