Hotwire Discussion

Respond with Turbo Streams on GETs - Example to discuss

I spend some time thinking about return with turbo streams on GETs (index, show) and why that is not a feature provided by turbo.

I found an interesting discussion from early this year where different people were discussing there.

Sean mentioned why he think that is an anti pattern:

It would be possible for the behavior to be triggered by an <a> element, but that undercuts the standard HTML semantics that an <a> element references another resource and drives navigation, and that <button> elements drive behavior on the current page.

And that makes sense to me. But the scenario that I found is using tabs. Imagine that we have a tabs component where the labels on the tab should load a counter of the list that we present on the content of that tab. And on the content we have a turbo frame with src to load that content asynchronously but we want to update the content and the counter on the response. Example:

How correct that is? This is the example that I found where I think I need to return with turbo stream on an index action but maybe you found better ways to do it or you already resolved it.