iTranslated by AI

The content below is an AI-generated translation. This is an experimental feature, and may contain errors. View original article
🙌

Using <turbo-stream-source> with Hono

に公開

Adding server-side push support to "Rendering Turbo Streams responses with Hono"
https://zenn.dev/laiso/articles/30c4274d4b7c69

Key Points

  • By connecting to a stream source, rendering instructions can be issued from the server to the client.
  • This can be used for implementations such as group chats, for example.
  • Prepare an endpoint for WebSockets or EventSource (SSE).

DEMO (WebSockets version): https://hono-turbo-stream.laiso.workers.dev/

Challenges

  • Reconnection logic needs to be written for WebSocket connections from Turbo when they are disconnected.
    • There might be hints in the Rails implementation, but I haven't investigated it yet.
  • To build a full-fledged real-time application on Cloudflare Workers, a mechanism to broadcast changes from the server is required.

References

  1. https://turbo.hotwired.dev/handbook/streams#integration-with-server-side-frameworks
  2. https://github.com/honojs/hono/issues/1153#issuecomment-1767321332
  3. https://hono.dev/helpers/streaming

Discussion