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"
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.
- In cloudflare/workers-chat-demo, WebSocket handling is implemented through Durable Objects' fetch from Workers.
Discussion