Hasty Briefsbeta

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

7 hours ago
  • #RPC
  • #WebDevelopment
  • #TypeScript
  • Cap'n Web is a new RPC protocol designed for the web stack, inspired by Cap'n Proto but with web-friendly features.
  • It supports bidirectional calling, passing functions and objects by reference, and promise pipelining for efficient network usage.
  • Cap'n Web is trivial to set up, with minimal boilerplate and seamless TypeScript integration.
  • It works over HTTP, WebSocket, and postMessage(), and is compatible with browsers, Cloudflare Workers, and Node.js.
  • The protocol is based on JSON with preprocessing for special types, making it human-readable and easy to debug.
  • Cap'n Web supports complex security patterns through its object-capability model, enabling secure authentication flows.
  • It solves the 'waterfall' problem better than GraphQL by allowing natural JavaScript-style chaining of operations.
  • The protocol includes special handling for arrays with a domain-specific language for server-side transformations.
  • Cap'n Web is symmetric, with no strict client/server distinction, allowing flexible communication patterns.
  • The implementation is lightweight (<10kB min+gzip) and dependency-free, licensed under MIT.