What is Hotwire?
Hotwire is a new generation SPA(Single Page Application) solution without writing any JS. Yes, this is true, Without using hotwire it's hard to imagine like we can make SPA without writing any JS. Hotwire serves HTML over the wire, not JSON.
Here I am not going in-depth like how Hotwire works but I am here to share how Hotwire is good. I have added a hotwire tutorial link at the bottom of the blog.
How to use Hotwire in rails app?
Do not think too much, It's very quick to integrate hotwire in your rails app. You just need to add hotwire-rails gem and follow the instruction written in the gem doc. When you will run the generator you will see it will remove the Turbolinks. Hotwire turbo is a replacement for turbo.
How Hotwire turbo is different from Turbolinks?
Everybody knows about Turbolinks, So here we will talk about how Hotwire Turbo is different from Turbolinks. Turbolinks good but Hotwire Turbo is super. Turbolink load HTML get for get request and for Post request its reload the complete page and that make UX very bad. Hotwire Turbo is super because it will work for both getting and Post. So In both requests browser will not reload the assets. There are some other good features for Hotwire Turbo like Frames and Stream. You can read those in the official documentation.
Here our goal is to just inspire you for Hotwire and next we will come with some real-life problems and solutions. You can read more about hotwire https://hotwire.dev/. You can read next, Create Infinite scroller with Hotwire Turbo.
Want to hire ruby on rails technical advice, consult our technical experts.