What can Hono’s web socket helper do that Deno.upgradeWebSocket can’t?
Can someone explain the purpose of using the Hono WebSocket adapter? I'm working with Deno, and since Hono is an HTTP server and Deno has Deno.upgradeWebSocket, it seems like there's not much need for Hono's adapter. WebSocket messages don't go over HTTP, so there's no routing involved anyway. Am I missing something? 🤔
3 Replies
i'd highly recommend taking a look at the hono source code, and comparing the implementations for different runtimes
hono code is pretty clear and succinct
in general, hono provides adapter layers for different runtimes in order to offer devs a runtime-agnostic experience
runtimes aren't necessarily going to all support the same apis or behaviors, much less with the same syntax
i just took a look myself out of curiosity. its pretty striking how different the implementation requirements are for different runtimes. tbf, they're not unopinionated
Thanks for this, so it’s a compatibility layer. That makes sense. I’m not accustomed to reading TypeScript, I confess, but I will try to read it. Thanks! I wonder if this sort of thing is what WinterCG is supposed to address.
i wouldn't say there's a need to fully understand what's going on
but imo its helpful to see that X runtime requires more config, etc
if you continue to use hono, that'll become especially important when customizing primitives
i'm not familiar w WinterCG, but yeah, it looks like it's tackling the same problem from a different angle