any day now eventually). Overall, using Hotwire’s components is very similar to using Bootcamp, as both rely heavily rely on attributes and properties in your HTML tags.
On the other hand, having a dedicated npm project and front end (sans
turbo-frame content, of course), does support unit testing, at least based on some preliminary research. Given that’s also how the Stimulus guide assumes your project is set up, I’m also betting that’s the official best practice. I feel a little disappointed at the idea of having to build a separate front end, but that may be just the hype behind the idea that I could, in theory, write something with no true front end at all. Ultimately, ease of unit testing and code cleanliness (and organization) swayed me to not putting everything in a server-side template, although it feels good to know that I could have chosen not to and been fine.
I may still end up making at least part of my existing personal project into something that installs Stimulus and Turbo from CDN and loads controllers as
<script></script> tag modules, because I want to make that part easily downloadable, and I think that’ll likely be the best way to support that (the basic thought here being that on the backend I can just
wget an endpoint that would otherwise return the page itself, zip it up, and return the zip file). In general installing Stimulus via npm and deploying a separate front-end project via CDN is probably still the way to go.
I didn’t play with all of Turbo’s features, but I did spend a decent amount of time with Turbo frames, Hotwire’s approach to partial DOM refreshing. Specifically, using the fact that Turbo navigation integrates with browser history (including, as of version 7.1.0 of Turbo, Turbo frames if you so choose). This would let application users traverse through their activity on the page using the browser’s back and forward buttons, instead of relying on me to keep track of that sort of thing. I didn’t spend a lot of time messing with Turbo streams, but it’s something I can see being very useful for auto-refreshing content.
1 interesting interaction to bear in mind – I used Apache Freemarker as my templating engine, mostly because I had used in a previous project and it was pretty flexible. Like a lot of HTML templating engines, you designate the pieces you want to replace with data by wrapping it in