CloudflareKenton Varda
Cap'n Web: a new RPC system for browsers and web servers
Cap'n Web is a new RPC protocol and implementation in pure TypeScript, described as a spiritual sibling to Cap'n Proto and designed to fit neatly into the web stack. It is an object-capability RPC system with bidirectional calling, allows passing functions and objects by reference, and supports promise pipelining, enabling multiple dependent calls to be combined in a single network round trip.
Unlike Cap'n Proto, Cap'n Web has no schemas and uses JSON with a light preprocessing step for certain types, with out-of-the-box support for HTTP, WebSocket, and postMessage transports, and it runs across major browsers, Cloudflare Workers, and Node.js. The project is open source under the MIT licence and is intentionally lightweight, compressing to under 10 kB with no dependencies.
Cap'n Web also integrates with TypeScript for end-to-end type checking, while still acknowledging that runtime type checks remain the responsibility of the application. Cloudflare notes Cap'n Web is experimental, but it already underpins features such as the remote bindings in Wrangler, and the team invites you to try it out via GitHub.