Hotwire stands for HTML Over The Wire. It’s a collection of frameworks designed to build modern web applications without much JavaScript by sending HTML instead of JSON over the wire.
robertoheadshoot99 / Ruby
Ruby
A beginner-friendly yet detailed guide to understanding and implementing Hotwire in Ruby on Rails applications. Covers Turbo Drive, Turbo Frames, Turbo Streams, and Stimulus.
Hotwire Basics
What is Hotwire?
|
|
|
Components of Hotwire:
|
Turbo Drive
|
What it does: |
How to use: |
|
Opting out: |
Example: |
Turbo Frames
|
What it does: |
How to use: |
|
Example:
|
Updating a frame: |
Advanced Hotwire
Turbo Streams
|
What it does: |
|
Actions:
|
|
Example:
|
Stimulus
|
What it does: |
Core concepts:
|
|
Example Controller:
|
HTML Usage:
|
r
Hotwire in Ruby on Rails
Turbo Drive
|
Turbo Drive accelerates links and form submissions by avoiding full page reloads. |
|
How to use: |
|
Example:
|
|
Benefits:
|
|
Limitations:
|
Turbo Frames
|
Turbo Frames allow you to update parts of a page without a full reload. |
|
How to use: |
|
Example:
|
|
Benefits:
|
|
Limitations:
|
Turbo Streams
|
Turbo Streams deliver page changes over WebSocket, SSE, or in response to form submissions. |
|
How to use: |
|
Example:
|
|
Benefits:
|
|
Limitations:
|
Stimulus
|
Stimulus is a modest JavaScript framework for adding behavior to your HTML. |
|
How to use: |
|
Example:
|
|
Benefits:
|
|
Limitations:
|