If you are getting started with Rails it makes sense to read first: - https://guides.rubyonrails.org/ - https://brdn.design/articles/good-resources-to-learn-ruby-rails-in-2022
Let’s get acquainted with Rails Hotwire.
- Speeds up application (cause it prevents the whole page from reloading when you follow a link or submit a form).
- Simplify adding real-time features (https://turbo.hotwired.dev/handbook/streams).
- Hotwire Turbo provides the tooling to wrap your web app in a native iOS / Android shell (https://turbo.hotwired.dev/handbook/native).
- Pairs nicely with Rails thanks to https://github.com/hotwired/turbo-rails & https://github.com/hotwired/stimulus-rails.
It became possible with:
- the browser support for ES6 / ESM https://caniuse.com/?search=ecmascript%20module,
- WebSockets https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API,
- Web Components https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements
- import maps https://github.com/WICG/import-maps, https://github.com/rails/importmap-rails.
Hotwire consists of 3 technologies:
- Turbo https://turbo.hotwired.dev/, https://turbo.hotwired.dev/handbook/introduction, https://github.com/hotwired/turbo-rails
- Stimulus https://stimulus.hotwired.dev/, https://stimulus.hotwired.dev/handbook/introduction, https://github.com/hotwired/stimulus-rails
- Strada will premiere in 2022
Hotwire is the default front-end framework since Rails 7 (released on December 15, 2021).
Before Hotwire there was https://github.com/defunkt/jquery-pjax. It would asynchronysly fetch fragments of HTML from the server and updated the dom.