Hotwire Discussion

Can this be done: Turbo Streams from 2 servers on one page?

Here’s what I’m thinking of doing and am not sure it’s possible:

  • The page layout has two turbo-frames. On the left is navigation, loaded from www-foo-com. On the right is content, loaded from content-foo-com, content2-foo-com, and so on. The page itself loads from the same server/domain as the navigation: www-foo-com.
  • The left frame (navigation) gets updates from www-foo-com whenever there’s changes in status which need to be represented in the menu (i.e. more posts, etc.)
  • The right frame (content) can load from a variety of servers, based on what got selected from the navigation frame which causes the appropriate src to be set in the content side’s turbo-frame. But as users post updates to that content frame, it needs to be able to get async turbo-stream updates of new content added (a’la Twitter).

I know this all works when it all comes from one server as I have that running as a proof of concept. But I’d really like to be able to have a more scalable arrangement and allowing content to reside on multiple servers would accomplish that.

The question is: is this possible and if so, how? How do I rig the turbo-frames and streams in the content frame to drive off a different server? If it can’t be done or it’d be a mess to maintain, that’s fine. I can compose the navigation in a shared JS module. But it’d be cool to be able to do it all in Hotwire.