sor4chi / hono-do

A wrapper of Cloudflare Workers's Durable Object for Hono.
https://www.npmjs.com/package/hono-do
MIT License
81 stars 2 forks source link

How can a client (web browser) connect direct to Durable object via websocket #45

Open boygiandi opened 3 months ago

boygiandi commented 3 months ago

How can a client (web browser) connect direct to Durable object via websocket+hono?

sor4chi commented 3 months ago

Hi, @boygiandi. Please note that this is not directly related to Hono DO.

Actually, the Durable Objects technology itself is only accessible as a request from inside Cloudflare Workers.

So, if your requirement is to use Hono + WebSockets with Cloudflare Workers, you need to set a Binding from Cloudflare Workers created with Hono to Duralbe Objects and proxy the ws communication.

Here's an image of what it looks like

Client (browser) <-> Cloudflare Workers (you can use Hono here) <-> Durable Objects (you can use Hono DO here)