Hotwire: HTML Over The Wire
hotwired.dev
hotwired.dev
[0] https://hn.algolia.com/?dateRange=pastYear&prefix=true&query...
[1] https://hn.algolia.com/?dateRange=pastYear&prefix=true&query...
Principles of Rich Web Applications (rauchg.com) Nov 4, 2014 https://news.ycombinator.com/item?id=8559519
https://www.infoworld.com/article/2612250/application-develo...
https://shiggyenterprises.wordpress.com/2013/03/11/picking-a...
https://blog.emberjs.com/inside-fastboot-the-road-to-server-...
It's not just that the idea has been developed over and over, but it is constantly hyped as a return to the golden past, and yet never gets the love that new client side spa messes end up attracting.
later on I figured out that what I was doing was generalizing hypermedia controls, but that took me years to figure out.
I do enjoy the lols I will admit that, hopefully as much at my own expense as anyone
Not pejorative btw - just a phrase to refer to the current article.
A good thread for understanding the different ways people think of it. I always go with @speg's interpretation, because the pejorative meaning just isn't used that frequently on HN:
> I tend to rethink of it as "the featured article".
I don't think "feels like 37 Signals took the same idea and is trying really hard to sell it" is very fair (I've never seen them try to "sell it" at all, much less "very hard"). Regardless, you're allowed to "steal" ideas.
I know people complain about any and all reposts in the first place (https://xkcd.com/1053), but obviously there should be a priority on teaching people things they didn't already know instead of punishing people that never read old news.
Re: the meta question, dang's policy that he repeats a lot is that reposts are fine every year or so [0]. Individuals may obviously disagree, but that's the rule that's actually enforced.
Hotwire and htmx both look like good products to me.
Agree they both look good products. But put the websites side by side and ask what page has had more marketing effort put into it and I’ll think you’ll see the commenter point.
Can I come live in whatever bizarro world you're in? I've never heard of Hotwire before but I'm up to my ears with htmx this and htmx that. It's impossible to spend a minute on Youtube without seeing programmer influencers with their moronic thumbnails featuring their face twerks next to htmx.
I still use React for more complex projects but it’s always a breath of fresh air to be able to write everything in Blade/PHP while keeping the reactive UI elements.
Edit: Although I have not used, I remember seeing this package which lets you render React/Vue components within Livewire when you need it: https://minglejs.unitedbycode.com/ an interesting escape hatch for when you want to pull in existing packages
While comparing with htmx it feels more developer focus than tech focus, but I believe the race between the two will depend on which one is integrated with your backend framework.
The difference is developer behavior that each framework encourages.
While htmx/turbo focus in just couple of helpers and then leave you with the full HTML/JS, in a react ecosystem you end having with 3 party components, and a state management system and build system that will change in 10 months. I don't say it isn't justify and that it have its pros, but it's a rabbit hole in my experience, where you easily end fighting with the framework than focusing on business.
Really don't understand the argument that React apps must be rewritten all the time. Most of our code is still old class components that still work in the latest version of React.
Can you imagine needing to fix a bug requiring a dependency (upon dependency and so on and so on and so on) update on code you haven’t touched for a year and suddenly having a herd of Yak like that need shaving?
Re: Typescript 4 => 5 that should be a trivial migration. All we needed was to bump our node version IIRC.
And yes I can imagine the sort of bug you describe, because I'm the guy who fixes these sorts of things on my team. Usually just a few hours of head banging once or twice a year. Though the apps I've built on Vite have never required this. Really cannot recommend Vite highly enough for web frontend tooling.
IMO PWA is a client issue and should be handled client side without introducing server dependencies.
However, I will argue that 80% of PWA exist to have proper push notifications, or faster development than native.
Hotwire: HTML over the Wire - https://news.ycombinator.com/item?id=25507942 - Dec 2020 (545 comments)
Also related:
Why Hotwire Could be the Future of Front-end Dev - https://news.ycombinator.com/item?id=26195969 - Feb 2021 (6 comments)
Hotwire: A new old way to build web apps - https://news.ycombinator.com/item?id=25942864 - Jan 2021 (56 comments)
(This comes up a lot! https://news.ycombinator.com/item?id=35668525)
And for infinite pages, a long forgotten technique: for scrolling or continuing content, you could use "multipart" since the 90s, effectively streaming the additional page content to the user as you got more bytes to send them.
Prototype.js and jQuery had a big hand in the latter.
The big inbetween OWA and Gmail, was Oddpost, which was also IE only, and was purchased by Yahoo three months after gmails April Fool announcement, to become Yahoo Mail. In a roundabout way, you can argue gmail was a copy of what was eventually Yahoo Mail.
I might be wrong, but I think even early versions of Gmail did something similar.
Started in 2000 in Exchange/Outlook web and took a year or two to become prevalent in the browsers and other places.
https://medium.com/@mohamedtayee3/make-an-http-request-in-ja...
AJAX streamlined the process, but there were a lot of hacky ways to get similar dynamic HTML effects. I like the idea of keeping the HTTP connection open, but that seems quite resource intensive… particularly for the early 2000s.
I bet ASP had something similar too around the same time
Basically the server sends a multipart content type header, never sends a content size, and simply doesn’t terminate the connection, so the browser just waits patiently for more parts and renders them as they come. My team experimented with it a bit back in 2000 for doing what would eventually be termed JSONP Streaming. It was really cool tech, but we didn’t have a practical application for it.
For highly interactive web apps you would still benefit from a SPA since that's what they're designed for.
Most of the complexity, especially the UI part, has been self-inflicted. The old ways are very much not outdated, and are actually coming back.
There is a whole young generation of devs who came into the job at the stupidest possible time, when the industry convinced them that every web application has to be an overcomplicated, insufferable mess.
In the face of medium-high latency, stuff behaves in an unpredictable/buggy way. Boxes open with no content. Links don't work like you'd hope. Lots of actions in quick succession don't abort in a way I'd find intuitive. It just feels off.
As bad as an SPA might be, this is a step away from UI feeling native and natural, in my opinion.
Last week, someone posted online how Hey (created by DHH, who also created Hotwire and Rails) is slow when opening a modal: https://x.com/noahflk/status/1795758603577545035
It created a bunch of heated conversation (DHH saying the original video was throttled, other people saying Hotwire is too reliant on the network if a modal needs time to load, people defending Rails/Hotwire, people disagreeing with its approach, etc...).
Basically, it's been a big topic on Twitter the past week.
It was. Author said as much: "This is slow on purpose asa demonstration. This isn't meant to show the experience someone in SF on a fancy MacBook with Gigabit internet has. No matter which tech, they're good. It's about the person on a cheap laptop on slow mobile internet." https://x.com/noahflk/status/1795855075526471915
People also pointed out that the Google Calendar SPA is much slower.
And not like "SF Gigabit internet" and "highly throttled 3G" are the only two options...
The original post was highly misleading. Basically just a lie.
https://github.com/josephernest/Swap
Used it for a few projects it works well !
My No-React tech stack is Alpine.js, Hotwire, EJS, and Express. Works very nicely for simpler sites.
Though for the majority of the sites I make, React wins almost every time since it's way easier to use as a templating and interactivity engine. And Tailwind works a lot better with React.
It may be intentional that it's relatively low key, or broader promotion is at least a non-goal of the project. But if you're still doing anything with jquery - rails or not - you owe it to yourself to look at this as a great replacement, and a very strong competitor to bloated client side frameworks for most webapps.
There are also helpers to build webview apps for both IOS and Android too [0].
I had the same question, then watched the video to get the answer.
You can Google Hotwire with Django, or Laravel, or many others (https://hotwire.io/frameworks).
The linked page shows only integrating Hotwire with Ruby on Rails, giving me my original impression.
Framework agnostic but Ruby-only it seems.
If your backend can send templates down the websocket, you can use Hotwire.
Rails has a lot of affordances for Hotwire and is the back end framework for which Hotwire was originally written.
The stimulus JavaScript controllers (not to be mistaken with the Rails mvc controllers) are reusable and nest-able which makes them very powerful and quite fun to write.
Turbolinks is the HTMX-Boost before HTMX was HTMX.
However I faced some other new frustration, such as when trying to make a dynamic nested form (similar to cocoon gem) but only with hotwire stack (turbo frame/stream). It is also hard to think of each hotwire controller as a component, you might face some problems when trying to do some nesting.
I think Hotwire will be a perfect fit if you want a traditional websites with a few dynamic, interactive features. If your website is too much app-like, you should consider switching the frontend part to SPA entirely.
For a website, SEO is important hence good ol html server rendering wins. There isn’t much interactivity.
For an app, how fast UI responds to user input matters. This is where JavaScript shines because interactive logic lives in the client device. User could be under a tunnel or offline, and a well written app will work.
Hey app had some Twitter discussions (can’t find thread), that it slows down to respond to clicks on 3G speeds. Because it had to call the server to load what UI snippet to show to user.
Essentially - choose the tech that fixes the best user experience.
Turbo is wonderful and seemingly straightforward, but also has some real hidden gems that aren’t well-documented (a problem which plagues Stimulus as well).
Stimulus is also great, but you can’t go into it expecting React. State management can get very tedious.
I use Turbo and Stimulus for most interactions in my current project, but I pull in Preact and HTM where I really need them. It’s trivial to have a Stimulus controller mount a Preact component and sync state between them, so it’s all very transparent.
Surprised something like this wouldn't have any example code or demos to look at.
It’s really very disappointing.
I'm no JavaScript fanboy, but I'm also not bent on avoiding it at all costs shrug.
Not just because it’s decoupled from the backend api. The React/Vue ecosystems have a lot more useful open source components, and you can build faster, more cache friendly front ends, among other benefits.
I agree React is more complex, but as with many things if you are gonna need it then it’s great to have started with it.
I also use Hotwire/Stimulus and haven't run into any issues yet. Happy to share links with you on anything I know about.
Not sure what this is in response to, sorry.
I appreciate there are projects which will hit no limits with the Hotwire/stimulus/turbo mix. I’ve worked on them before and would choose Hotwire when appropriate (eg for government services Hotwire is perfect).
The SSR vs CSR debate is quite tired and played out at this point, and doesn’t lend itself to thoughtful threads… While hotwire does make it easier to do SSR with progressive enhancement, for some projects it’s easier for me to just build a single “enhanced” experience with React (for performance, ecosystem, and IME UX).
I am a user of Hey and what I can say is the UX is dreadful. I am seeing spinner way more than I can handle, really.
I assume this proposal is to moving backwards.
Instead we would need to sort of data on client and full-body client app, doesn’t matter if it’s for web, ios, android. And the data should be given back to us - users.
The problem with that is that services like Hey become a true commodity and doesn’t lock users by keep exclusive access to their data anymore. So it’s to be figured out what is the new business model.
I have planned it for the second half of this year though.
Context for why this might be coming up now:
https://phoenixframework.org/blog/phoenix-liveview-1.0-relea...
Even if you redefine “the wire” to “XHR requests” or “Ajax requests” it’s still weird to treat this as a revolutionary thing since the “X” in XHR and Ajax is “XML” which is just a sibling markup language to HTML.
Also, IIRC the original Rails approach to Ajax like 15 years ago or so was sending page partials like this.
It feels like we’re going in circles.
(I’ve also never been impressed with their “turbo links” which just seem like “we think we can do caching better than the browser makers” and thus dubious. Core Rails seems great but I’m always wary of this stuff at the edges with the extra dollop of hype.)
Idk why he does videos like this because it ends up reflecting poorly on Vercel or other companies he's associated with.
In the video he sets the chrome throttle option to slow 3G, and that adds large restrictions on bandwidth, and a ton of latency. He states that he is not doing so, and that adding latency can't be done in the browser. That is literally what the option does.
If you add seconds of latency then requests will take seconds, who would imagine...
A. The complaint about how every keypress goes to the server says literally nothing about HTML over the wire. It’s obviously how Hey chose to do things (or it was a bug), but Theo should be experienced enough to know that most approaches don’t need to be like this. Attributing a sloppy implementation by Hey onto a video about Rails as a whole is inflammatory.
B. And if he isn’t, and doesn’t realize that HTML over the wire doesn’t mean you can’t have any JavaScript, he should stop talking about what he does not understand.
C. This is personal taste, but a man with his hair style shows he can’t recognize good taste if it hit him in the face.
This is why we abandoned DHTML 2 decades ago, invested in jQuery to encapsulate variations in JavaScript across browsers and worked hard on standardizing JS so you could write code once and have it work across vendors.
This is how I’ve implemented my website. I am quite aware of how this is done, I suggest you look further into it.
I hate how there are JS influencers now. And I hate how they repeatedly cause drama for clicks. There will be a fresh idiotic topic bubbling up every few weeks. It will be semicolons soon, I am sure of it. I hate it.