Turbo morphing Rails support means that when a page refreshes, Turbo compares the new HTML with the page in the browser and changes only the elements that differ, instead of replacing the whole body. Scroll position, focus and unchanged elements stay as they are. Combined with broadcasts_refreshes, it gives you live-updating pages without writing a Turbo Stream template for every change.
This article shows how to turn morphing on, how to broadcast refreshes from a model, and where it goes wrong: forms, JavaScript state, and a duplicate broadcast I found while testing. It is for Rails developers using Hotwire, and for teams deciding whether Hotwire is enough before they reach for a JavaScript framework. For that wider decision, see my comparison of Ruby on Rails vs Next.js.
I ran the model code and tests in this article against turbo-rails 2.0.23 on Rails 8.1.4.1 and Ruby 3.3.6, in a minimal app with SQLite. I did not run the browser behavior (morphing, scroll, focus). Those parts come from the Turbo handbook, so check them in your own app.
What page refreshes and morphing are
Turbo has two parts here, and they are separate features.
A page refresh is Turbo loading the current page again. The Turbo handbook gives the typical case: you submit a form and the server redirects back to the same page. A refresh Turbo Stream action can also trigger one.
Morphing is how that refresh is applied. By default, Turbo replaces the page body (replace). With morphing, it uses the idiomorph library to update only the changed elements.
You can use either one alone. The useful combination is both: a refresh that is cheap for the user, because the page does not flash or jump.
Turn it on
Rails 7 and newer apps already include turbo-rails unless you generated them with --skip-hotwire. As of November 7, 2026, the latest turbo-rails release on RubyGems is 2.0.23. The gem is MIT-licensed and lives in the hotwired/turbo-rails repository.
Morphing is opt-in. Add two meta tags to the layout head. The default Rails layout already has a yield :head, so you can do it per page:
<%# app/views/projects/show.html.erb %>
<% content_for :head do %>
<meta name="turbo-refresh-method" content="morph">
<meta name="turbo-refresh-scroll" content="preserve">
<% end %>The handbook documents these values:
| Meta tag | Values | Default |
|---|---|---|
turbo-refresh-method |
morph, replace |
replace |
turbo-refresh-scroll |
preserve, reset |
reset |
preserve keeps both the vertical and horizontal scroll position.
Start per page, not in the main layout. thoughtbot’s write-up on Turbo morphing warns that enabling morphing globally can break JavaScript state. Its example is a <details> element that reopens after a refresh. Opt in on the pages that need it, and widen later.
Broadcast refreshes from a model
Morphing alone refreshes the page for the user who made the change. To refresh everyone else who is looking at the same page, broadcast a refresh over Action Cable.
Here is a project with tasks:
# app/models/project.rb
class Project < ApplicationRecord
has_many :tasks, dependent: :destroy
broadcasts_refreshes
end# app/models/task.rb
class Task < ApplicationRecord
belongs_to :project
broadcasts_refreshes_to :project
endThen subscribe the page to the project’s stream:
<%# app/views/projects/show.html.erb %>
<%= turbo_stream_from @project %>Now creating, updating or destroying a task sends a refresh to every browser subscribed to that project. Each browser reloads the page, and morphing applies only the differences. You did not write a partial or a Turbo Stream template.
This is the main appeal. A broadcasts_refreshes line replaces a set of per-action stream templates, and the page is always rendered by the same code path as a normal visit.
Test it
I tested the model side with Rails’ own test tools. Turbo broadcasts refreshes through an Active Job job, so the test must run jobs:
# test/models/broadcast_test.rb
require "test_helper"
class BroadcastTest < ActiveSupport::TestCase
include ActiveJob::TestHelper
test "creating a task broadcasts a refresh on the project stream" do
project = Project.create!(name: "Launch")
assert_turbo_stream_broadcasts(project) do
perform_enqueued_jobs do
project.tasks.create!(title: "Write docs")
end
end
end
endWithout perform_enqueued_jobs, my first version of this test failed with “Expected 1 Turbo Stream broadcast … but there were 0”. The refresh is queued, not sent inline.
Two setup notes. In my minimal app (rails new --minimal) I had to load Action Cable and Active Job explicitly, because turbo-rails only adds broadcasts_refreshes and the test helpers when both are present. I did not run this in a default rails new app, which loads both frameworks, so I expect it to work there without extra setup.
A pitfall: touching the parent doubles the broadcast
Many Rails apps use belongs_to :project, touch: true so the parent’s updated_at changes with its children. That is useful for caching. It also interacts with broadcasts_refreshes.
I changed Task to use touch: true and counted the jobs created by one tasks.create!:
test "the touch adds a second refresh job" do
project = Project.create!(name: "Launch")
assert_enqueued_jobs 2, only: Turbo::Streams::BroadcastStreamJob do
project.tasks.create!(title: "Write docs")
end
endThe count was 2: one from the task’s broadcasts_refreshes_to :project, and one from the project itself, since the touch updates the project and Project also calls broadcasts_refreshes.
Does this matter? The Turbo handbook text I read does not mention debouncing. The turbo-rails source includes a debouncer for refresh broadcasts, and 37signals’ write-up on morphing says that when several refreshes are generated in a row, only the last one is sent. Turbo’s test setup swaps in an immediate debouncer, which is why I saw both jobs. I did not measure production behavior, so don’t assume either way. If you want one broadcast, pick one of the two models to broadcast.
Keep state with data-turbo-permanent and frames
A morph can still disturb things the user is interacting with. Two tools from the handbook help.
Add data-turbo-permanent to an element Turbo should leave alone, such as an open popover:
<div id="share-popover" data-turbo-permanent>
<%# content the user may have open %>
</div>For content loaded after the first render, such as a paginated list in a frame, set refresh="morph" on the frame so its content is morphed instead of removed:
<turbo-frame id="activity" refresh="morph" src="<%= activity_path %>">
</turbo-frame>Turbo 8.0.20 fixed a bug where frames with refresh="morph" were lost on page refreshes, so keep Turbo up to date (the release notes are on the hotwired/turbo releases page).
What to watch in production
- Action Cable adapter. In a new Rails 8.1.4.1 app, the generated
config/cable.ymluses theasyncadapter in development, which only broadcasts inside one process, and Redis in production. A broadcast sent from a console will not reach a browser connected to a separate server process in development. Pick a production adapter on purpose, and test with two browsers. - Job processing. Broadcasts go through Active Job. If your queue is slow, “live” updates are late. My guide to Solid Queue in Rails 8 covers queue setup.
- Authorization.
turbo_stream_fromsubscribes through a signed stream name. A refresh only tells the browser to reload the page, and the reload goes through your normal controller, so your usual authorization applies to what the user sees. - Page cost. Every broadcast makes every subscribed browser request the full page. Keep the action fast, and avoid broadcasting on every keystroke or bulk import.
- Forms. Do not broadcast refreshes to the user who is typing in a form on the same page without testing it, because a morph can interact with the form state.
Morphing vs Turbo Streams vs a JavaScript framework
| Approach | Best for | Cost |
|---|---|---|
Morphing with broadcasts_refreshes |
Pages where the server already renders the right HTML, and many small changes | Each refresh reloads the whole page |
| Targeted Turbo Streams | A few precise updates, such as appending a chat message | More templates to maintain |
| React or another client framework | Rich client-side interaction, offline use | A second app to build and maintain |
I recommend starting with morphing for dashboards, admin screens and collaborative lists, and using targeted streams where a full refresh is too heavy. That is an opinion from building Rails apps, not a benchmark.
If you are weighing Hotwire against React for a specific product, I offer Ruby on Rails development that includes Hotwire frontends and can help you decide with your data in front of us.
If you’re weighing Rails itself, here’s whether Ruby on Rails is still relevant.
Conclusion
Turbo morphing in Rails turns a normal page reload into a small DOM update, and broadcasts_refreshes pushes that reload to everyone viewing the page. Enable it per page with two meta tags, broadcast from the model that owns the page, protect interactive elements with data-turbo-permanent, and test the broadcast with perform_enqueued_jobs. Watch for duplicate broadcasts when you use touch: true.
Limits: every refresh is a full page request, and morphing can surprise you with JavaScript state. For very fine-grained updates, targeted Turbo Streams are still the better tool.
I build and maintain Hotwire and React frontends on Rails apps, from real-time dashboards to full SaaS products. If you want help adding live updates to an existing app, send me a short brief and book a discovery call.
Frequently asked questions
What is Turbo morphing in Rails?
It is a way for Turbo to apply a page refresh by updating only the changed parts of the page, using the idiomorph library, instead of replacing the whole body. You turn it on with the turbo-refresh-method meta tag set to morph.
What is the difference between Turbo morphing and Turbo Streams?
Morphing refreshes a whole page and updates the differences. Turbo Streams apply specific actions, like append or replace, to specific targets. A refresh stream action connects the two: it tells the browser to reload the page, and morphing then applies the result.
Does Turbo morphing work in Rails 8?
Yes. New Rails 8 apps include turbo-rails, and the latest release as of November 7, 2026 is 2.0.23. The morphing and broadcasts_refreshes features come from Turbo 8 and turbo-rails 2.0 and later.
How do I keep scroll position when a page refreshes?
Add <meta name="turbo-refresh-scroll" content="preserve">. The default is reset.
How do I stop Turbo from morphing an element?
Add the data-turbo-permanent attribute to it. The handbook uses an open popover as the example.
Why does my broadcast not arrive in development?
The default development adapter is async, which only works inside one process. A broadcast from rails console will not reach a browser connected to another server process. Broadcast from the app itself, or use a shared adapter.
Why does my test say there were 0 broadcasts?
Refresh broadcasts are sent by an Active Job job. Wrap the code in perform_enqueued_jobs, as in the test above.


