While prototyping some new features for this site, I stumbled upon some unusual code in a Durable Objects guide. Surprisingly, it covered functionalities I had not seen documented, at least not within the past couple of months.
I had no idea you could directly call methods on Durable Object stubs! This discovery eliminates the need for cumbersome request routing boilerplate, trpc
, and the often unnecessary low-level decisions. Simply obtain a handle to your object and call methods on it. Amazing.
Source: Cloudflare Docs
It turns out I'm not too far behind the times, although I'm puzzled about how I missed this announcement from April: JavaScript Native RPC on Cloudflare (spoiler: this feature extends beyond just Durable Objects). I’m glad I discovered this when I did.