# Hotwire: Reactive Rails with no JavaScript?

> Take a deep dive into building reactive Rails applications with Hotwire Turbo and only a pinch of custom JavaScript. This article compliments the RailsConf 2021 talk by Vladimir Dementyev.

- Date: 2021-04-12T00:00:00.000Z
- Authors: Vladimir Dementyev
- Categories: Rails
- URL: https://evilmartians.com/chronicles/hotwire-reactive-rails-with-no-javascript

---

It's time to actually conjure up the long-teased [**new magic**](https://twitter.com/dhh/status/1275901955995385856) by DHH & Co. and learn to use [Hotwire][] beyond 5-minute tutorials. This umbrella term, behind libraries for building modern web interfaces seemingly without any effort or JavaScript, is on everyone's tongue since the big unveil this year. The HTML-over-the-wire approach is making ripples through the Rails universe: countless blogs, Reddit posts, screencasts, and _five_ [RailsConf talks][railsconf-program] this year, including the one by yours truly, are dedicated to it. I want to take more time to explain Hotwire thoroughly—with code examples and testing strategies. As my favorite rock band would say, let's get "Hotwired" to ~~self-destruct~~ ...learn new tricks!

## Life is short

**To see the Hotwire-ing of a Rails 6 app at a glance, without any further fluff, feel free to study [this PR](https://github.com/anycable/anycable_rails_demo/pull/16).**

This article explains the code above in great detail. It's an adaptation (and an extension of) my [RailsConf 2021](https://railsconf.com) talk: ["Frontendless Rails frontend"](https://railsconf.com/program/sessions#session-1118), which is already available online for all RailsConf attendees. If you don't have conference tickets, don't worry: you can find the slide deck [here](https://noti.st/palkan/eVl0xO/frontendless-rails-frontend), and the same page will be updated with the video once all the talks have become public.

## "This is the way"

For the last five years, I've been doing mostly _pure_ backend development: REST and GraphQL APIs, WebSocket, gRPC, databases, caches—pretty much all there is to do "behind-the-veil".

The entire frontend-revolution has passed me over like a giant wave: I still don't understand why we need to stuff every web app with _reacts_ and _webpacks_. The classic HTML-first **Rails way** was _my way_ (or the highway 😉). Remember the days when the JavaScript in your application didn't require its own MVC (or MVVM) to function? I miss those days. And these days are quietly making a hell of a comeback.

Today, we're witnessing the rise of _HTML-over-the-wire_ (yes, it's an actual term now). Sparked by [Phoenix LiveView](https://github.com/phoenixframework/phoenix_live_view), this approach, based on pushing backend-rendered templates over WebSocket to all connected clients, has gotten a lot of traction in the Rails community, thanks to the [StimulusReflex][] family of gems. It was finally blessed by DHH himself when he introduced [Hotwire](https://hotwire.dev/) to the world early this year.

Are we standing on the verge of yet another global paradigm shift in web development? Will we go back to the simple mental model of server-rendered templates, just this time with all the bells and whistles of reactive interfaces at little-to-no effort? As much as I'd love that, I realize it's wishful thinking: Big Tech is too invested in client-rendered apps ever to go back. Frontend development in the 2020s is a separate _qualification_ and a separate _industry_ with its own entry requirements; there's no way we'll see "full-stack" again.

However, HOTWire (see that acronym right there? Smart on Basecamp's part, huh?) provides a much-needed alternative to the, shall we say "complicated", rocket science of modern client-side programming for the browser.

> For the Rails developer who's tired of doing API-only apps with no control over the presentation and who misses creating a _user experiences_ as an escape from wrangling SQL and JSONs forty hours a week, Hotwire is a long-sought breath of fresh air that makes web development _fun_ again.

In this post, I'd like to demonstrate how to apply the HTML-over-the-wire philosophy to an existing Rails application through Hotwire. As with most of my recent articles, I will use my [AnyCable demo application][anycable-demo] as a guinea pig.

And this app fits the task well: it's interactive and reactive, driven by Turbolinks and a handful of custom (Java)scripts, and it also boasts decent system tests coverage (meaning we can refactor safely). Our _hotwire-ification_ will be executed with some easy-to-follow steps:

- [From Turbolinks to Turbo Drive](#from-turbolinks-to-turbo-drive)
- [Framing with Turbo Frames](#framing-with-turbo-frames)
- [Streaming with Turbo Streams](#streaming-with-turbo-streams)
- [Beyond Turbo, or using Stimulus and custom elements](#beyond-turbo-or-using-stimulus-and-custom-elements)

## From Turbolinks to Turbo Drive

[Turbolinks][] has been known in the Rails world for a long time; the [first major release](https://github.com/turbolinks/turbolinks-classic/commit/41dd321407f837d9705de9d893f2847537676904) was published as early as 2013. However, in my early days, Rails developers followed a rule of thumb: _If your frontend is acting weird, try disabling Turbolinks_. Making third-party JS code compatible with Turbolink's _fake_ (read: `pushState` + AJAX) navigation was not a walk in the park.

I stopped avoiding Turbolinks when [StimulusJS][stimulus] came out. It radically solved the problem of connecting and disconnecting _JavaScript sprinkles_ by relying on the modern [DOM mutation APIs](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver). Turbolinks combined with Stimulus for code organization, and DOM manipulation yields an effortless "SPA" experience at a fraction of React/Angular development costs.

The same good old Turbolinks has now been re-branded as _Turbo Drive_, as it literally _drives_ [Turbo][turbo]—the heart of Hotwire package deal.

> If your app already uses Turbolinks (and mine did), switching to Turbo Drive is dead simple. It's just about renaming some things.

All you need is to replace `turbolinks` with `@hotwired/turbo-rails` in your `package.json` file, and in the `Gemfile`—replace `turbolinks` with `turbo-rails`.

The initialization code looks a little bit different and is now even more concise:

```diff
- import Turbolinks from 'turbolinks';

- Turbolinks.start();
+ import "@hotwired/turbo"
```

Note that we don't need to start Turbo Drive manually (and we [can't stop it](https://github.com/hotwired/turbo/issues/198)).

Some "Find & Replace" is required to update all the HTML data attributes from `data-turbolinks` to `data-turbo`.

The only change that took me some time to figure out was dealing with **forms and redirects**. Previously, with Turbolinks, I used remote forms (`remote: true`) and the [Redirection concern](https://github.com/turbolinks/turbolinks-rails/blob/master/lib/turbolinks/redirection.rb) to respond with JavaScript templates. Turbo Drive has its own built-in support for hijacking forms, so `remote: true` is no longer required. However, it turned out that the redirection code must be updated. Or, more precisely, the redirection **status code**:

```diff
- redirect_to workspace
+ redirect_to workspace, status: :see_other
```

Using the somewhat obscure _See Other_ HTTP response code (303) is a smart choice: it allows Turbo to rely on the native Fetch API `redirect: "follow"` option, so you don't have to explicitly initiate another request to fetch the new content after form submission. According to [the specification](https://fetch.spec.whatwg.org/#concept-http-redirect-fetch), _"if status is 303 and request's method is not `GET` or `HEAD`"_, a `GET` request must be performed automatically. Compare this with _"if status is 301 or 302 and request’s method is `POST`"_—see the difference?

Other 3xx statuses are only meant for POST requests, while with Rails we usually use POST, PATCH, PUT, and DELETE.

## Framing with Turbo Frames

Time to move on to something truly new: Turbo Frames.

Turbo Frames brings seamless updates to parts of the page (not to the whole page as Turbo Drive does). We can say it's very similar to what `<iframe>` does but without creating separate windows, DOM trees, and security nightmares that come with it.

Let's take a look at an example in use.

The AnyCable demo application (called _AnyWork_) allows you to create dashboards with multiple ToDo lists and a chat. A user can interact with items in different lists: add them, delete them, and mark them as completed.

Originally, completing and deleting items were backed by AJAX requests and a [custom Stimulus controller][list-controller-original]. I decided to rewrite this functionality using Turbo Frames to go HTML all-in.

How can we decompose our ToDo lists to handle individual item updates? Let's turn each item into a frame!

```erb
<!-- _item.html.rb -->
<%= turbo_frame_tag dom_id(item) do %>
  ">
    <%= form_for item do |f| %>
      <!-- ... -->
    <% end %>
    <%= button_to item_path(item), method: :delete %>
      <!-- ... -->
    <% end %>

<% end %>
```

We did three important things here:

- wrapped our item container into a `<turbo-frame>` tag via the helper and passed a unique identifier (check out the handy [dom_id](https://api.rubyonrails.org/classes/ActionView/RecordIdentifier.html#method-i-dom_id) method from `ActionView`);
- added an HTML form to make Turbo intercept submissions and update the contents of the frame; and
- used the `button_to` helper with `method: :delete`, which also creates an HTML form under the hood.

Now, whenever a form is submitted within the frame, Turbo intercepts the submissions, performs an AJAX request, extracts a frame with the same ID from the response HTML, and replaces the contents of this frame.

> All of the above works with exactly zero hand-written JavaScript!

Let's take a look at our updated controller code:

```ruby
class ItemsController < ApplicationController
  def update
    item.update!(item_params)

    render partial: "item", locals: { item }
  end

  def destroy
    item.destroy!

    render partial: "item", locals: { item }
  end
end
```

Note that we respond with the same partial when we delete an item. However, we need to remove the item's HTML node, not update it. How can we do that? We can respond with an empty frame! Let's update our partial to do that:

```erb
<!-- _item.html.rb -->
<%= turbo_frame_tag dom_id(item) do %>
  <% unless item.destroyed? %>
    ">
      <!-- ... -->

  <% end %>
<% end %>
```

You've probably asked yourself the question: "How do we trigger form submission when marking an item as completed?" In other words, how can we make the checkbox state change trigger submit a form? We can do that by defining an _inline_ event listener:

```html
<%= f.check_box :completed, onchange: "this.form.requestSubmit();" %>
```

_**NB**: Using `requestSubmit()` and not `submit()` is important: the former triggers a "submit" event that could be intercepted by Turbo, and the latter does not._

The `requestSubmit()` is not supported by all modern browsers yet. Consider using [the polyfill][form-request-submit-polyfill].

To sum it up, we can get rid of _all the custom JS_ for this particular functionality just by altering our HTML template a bit and simplifying the controller's code. I'm excited, aren't you?

We can go further and convert our lists into frames, too. This would allow us to switch from Turbo Drive page updates to specific node updates when adding a new item. You can try this at home!

Imagine you also want to display a flash notification to a user whenever an item has been completed or deleted ("Item has been successfully removed"). Can we do this with Turbo Frames? Sounds like we'd need to wrap our flash messages container into a frame and push the updated HTML along with the markup for the item. That was my initial idea, and it didn't work out: frame updates are scoped to the initiator frame. Thus, we can not update anything outside of it.

It's also possible to trigger a full page, or another frame update, from within a frame (see [the docs][turbo-frames-target-docs]). But, there is currently no way to update two independent frames.

After some research, I found out that [Turbo Streams][turbo-streams] could help with this.

## Streaming with Turbo Streams

Compared to Drive and Frames, [Turbo Streams][turbo-streams] is a completely new technology. Unlike those other two, Streams are explicit. Nothing happens _automagically_ and _you_ are in charge of what and when should be updated on a page. To do that, you'll need to make use of some special `<turbo-stream>` elements.

Let's take a look at this element from the example stream:

```html
<turbo-stream action="replace" target="flash-alerts">
  <template>

      <!--  -->

  </template>
</turbo-stream>
```

This element is responsible for replacing the node under DOM ID `flash-alerts` with the new HTML contents passed inside the `<template>` tag (note `action="replace"`). Whenever you _drop_ a `<turbo-stream>` element on the page, it immediately performs the action and destroys itself. Under the hood, it uses HTML [Custom Elements API](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements)—yet another example of using modern web APIs for the sake of developer happiness (i.e., less JavaScript 🙂).

If want to learn more, check out the source code of the `<turbo-stream>` element [here][stream_element.ts].

I would say that Turbo Streams are a declarative alternative to the JavaScript templates of old. In the 2010s we wrote it like this:

```js
// destroy.js.erb
$("#<%= dom_id(item) %>").remove();
```

And now we do the following:

```erb
<!--  destroy.html.erb -->
<%= turbo_stream.remove dom_id(item) %>
```

Currently, there are only five actions available: _append, prepend, replace, remove_, and _update_ (which replaces only the text content of the node). We'll talk about this limitation and how to overcome it below.

Let's return to our initial problem: showing the flash notification in response to the ToDo item's completion or deletion.

We want to respond with both `<turbo-frame>` and `<turbo-stream>` updates at once. How can we do that? Let's add a new partial template:

```erb
<!-- _item_update.html.erb -->
<%= render item %>

<%= turbo_stream.replace "flash-alerts" do %>
  <%= render "shared/alerts" %>
<% end %>
```

Add a little change to the `ItemsController`:

```diff
+    flash.now[:notice] = "Item has been updated"

-    render partial: "item", locals: { item }
+    render partial: "item_update", locals: { item }
```

Unfortunately, the code above doesn't work as expected: we don't see any flash alerts.
After digging through the [documentation][turbo-streams-mime-type-docs], I found that Turbo expects an HTTP response to have the `text/vnd.turbo-stream.html` content type in order to activate stream elements. Okay, let's do that:

```diff
-    render partial: "item_update", locals: { item }
+    render partial: "item_update", locals: { item }, content_type: "text/vnd.turbo-stream.html"
```

We now have the opposite situation: flash messages work, but the item's content is not being updated 😞. Am I asking too much from Hotwire? Reading through the Turbo source code, I found that mixing streams and frames like this [is not possible][stream_observer.ts].

It turns out, there are two ways to implement this functionality:

- Use streams for everything.
- Put `<turbo-stream>` inside the `<turbo-frame>`.

The second option, in my opinion, runs counter to the idea of reusing HTML partials for regular page loads and Turbo updates. So, I went with the first one:

```erb
<!-- _item_update.html.erb -->
<%= turbo_stream.replace dom_id(item) do %>
  <%= render item %>
<% end %>

<%= turbo_stream.replace "flash-alerts" do %>
  <%= render "shared/alerts" %>
<% end %>
```

Mission complete. But at what cost? We had to add a new template for this use case. And I'm afraid that in a real-world application, the number of such _ad hoc_ partials would grow as the app evolves.

**UPDATE (2021-04-13)**: Alex Takitani [suggested](https://twitter.com/alex_takitani/status/1381706025875730435?s=20) a more elegant solution: using a layout to update flash contents. We can define the application layout for Turbo Stream responses as follows:

```erb
<!-- layouts/application.turbo_stream.erb -->
<%= turbo_stream.replace "flash-alerts" do %>
  <%= render "shared/alerts" %>
<% end %>

<%= yield %>
```

Then, we need to remove the explicit rendering from the controller (because otherwise [layout wouldn't be used](https://github.com/hotwired/turbo-rails/issues/25)):

```diff
   def update
     item.update!(item_params)

     flash.now[:notice] = "Item has been updated"
-
-    render partial: "item_update", locals: { item }, content_type: "text/vnd.turbo-stream.html"
   end
```

_**NB**: Don't forget to add `format: :turbo_stream` to the corresponding requests in your controller/request specs to make implicit rendering work._

And let's convert our `_item_update` partial to the `update` Turbo Stream template:

```erb
<!-- update.turbo_stream.erb -->
<%= turbo_stream.replace dom_id(item) do %>
  <%= render item %>
<% end %>
```

Cool, right? This is the Rails way!

Now let's move to some _real_(-time) streaming.

Turbo Streams are often mentioned in the context of real-time updates (and are usually compared to [StimulusReflex][]).

Let's see how we can build lists synchronization on top of Turbo Streams:

Before Turbo, I had to add a custom Action Cable channel and a Stimulus controller to handle broadcasts. I also needed to take care of the message format as I had to distinguish between deletion and completion of the items. In other words, a lot of code to maintain.

Turbo Streams takes care of most of this: the `turbo-rails` gem comes with a general `Turbo::StreamChannel` and a helper (`#turbo_stream_from`) to create a subscription right from HTML:

```erb
<!-- worspaces/show.html.erb -->

  <%= turbo_stream_from workspace %>
  <!-- ... -->

```

In the controller, we already had the `#broadcast_new_item` and `#broadcast_changes` "after action" hooks responsible for broadcasting updates. All we need now is to switch to `Turbo::StreamChannel`:

Although we're using Action Cable here, Turbo Streams are transport-agnostic. You can push updates using any _cable_ you want, just write an adapter for it.

```diff
 def broadcast_changes
   return if item.errors.any?
   if item.destroyed?
-    ListChannel.broadcast_to list, type: "deleted", id: item.id
+    Turbo::StreamsChannel.broadcast_remove_to workspace, target: item
   else
-    ListChannel.broadcast_to list, type: "updated", id: item.id, desc: item.desc, completed: item.completed
+    Turbo::StreamsChannel.broadcast_replace_to workspace, target: item, partial: "items/item", locals: { item }
   end
 end
```

This migration went smoothly. ...Almost. All the controller unit tests that were verifying broadcasts (`#have_broadcasted_to`) have failed.

Unfortunately, Turbo Rails doesn't provide any testing tools (yet?), so I have to write my own, an [all-too-familiar tale](https://github.com/rails/rails/pull/33659):

```ruby
module Turbo::HaveBroadcastedToTurboMatcher
  include Turbo::Streams::StreamName

  def have_broadcasted_turbo_stream_to(*streamables, action:, target:) # rubocop:disable Naming/PredicateName
    target = target.respond_to?(:to_key) ? ActionView::RecordIdentifier.dom_id(target) : target
    have_broadcasted_to(stream_name_from(streamables))
      .with(a_string_matching(%(turbo-stream action="#{action}" target="#{target}")))
  end
end

RSpec.configure do |config|
  config.include Turbo::HaveBroadcastedToTurboMatcher
end
```

This is how I use my new matcher in tests:

```diff
 it "broadcasts a deleted message" do
-  expect { subject }.to have_broadcasted_to(ListChannel.broadcasting_for(list))
-    .with(type: "deleted", id: item.id)
+  expect { subject }.to have_broadcasted_turbo_stream_to(
+    workspace, action: :remove, target: item
+  )
 end
```

Going real-time with Turbo has gone well so far, and a bunch of code has been removed!

> And we still haven't written a single line of JavaScript code. Is this the real life? Is this just fantasy?

When am I going to wake up? Well, right now.

## Beyond Turbo, or using Stimulus and custom elements

During the Turbo migration, I stumbled upon a couple of use-cases where using the existing API was not enough, so I finally had to write some JavaScript code!

Use-case number one: adding new lists to the dashboard in real-time. How is it different from the list of items example from the previous chapter? The markup. Let's take a look at the dashboard layout:

```html

  ...
  ...

    <form>...</form>

```

The last element is always the new list form container. Whenever we add a new list, it's inserted right before the `#new_list` node. Do you recall that Turbo Streams supports only five actions? Do you see where the problem is? Here's the code I used originally:

That is where [CableReady][] from the StimulusReflex clan beats the competitor: it supports more than 30 actions, including `insert_adjacent_html`.

```js
handleUpdate(data) {
  this.formTarget.insertAdjacentHTML("beforebegin", data.html);
}
```

To implement similar behavior using Turbo Streams, we need to add a hack to move the list to the right place immediately after being added via the stream. So, let's add our own _JavaScript sprinkle_.

Let's first give our task a formal definition: _"When a new list item is appended to the workspace container, it should be positioned right before the new form element."_ The word _"when"_ here means that we need to observe the DOM and react to changes. Doesn't it sound familiar? Yes, we already mentioned the MutationObserver API in relation to Stimulus! Let's use it.

Luckily, we don't have to write advanced JavaScript to use this feature; we can use [stimulus-use][] (forgive me for this unavoidable tautology). Stimulus Use is a collection of useful _behaviors_ for Stimulus controllers, simple snippets to solve complex problems. In our case, we need the [useMutation][] behavior.

The code for the controller is pretty concise and self-explanatory:

```js
import { Controller } from "stimulus";
import { useMutation } from "stimulus-use";

export default class extends Controller {
  static targets = ["lists", "newForm"];

  connect() {
    [this.observeLists, this.unobserveLists] = useMutation(this, {
      element: this.listsTarget,
      childList: true,
    });
  }

  mutate(entries) {
    // There should only be one entry in entry.addedNodes when adding a new list via streams
    const entry = entries[0];

    if (!entry.addedNodes.length) return;

    // Disable observer while we modify the childList
    this.unobserveLists();
    // Move newForm to the end of the childList
    this.listsTarget.append(this.newFormTarget);
    this.observeLists();
  }
}
```

The problem is solved.

Let's talk about the second edge case: implementing the chat functionality.

We had a very simple chat attached to each dashboard: users can send ephemeral (not stored anywhere) messages and receive them in real-time. Messages have a different look depending on the context: _my_ messages have green borders are located to the left; _other_ messages are grey and located to the right. But we broadcast the same HTML to everyone connected to the chat. How can we let users feel the difference? That is a very common problem for chat-like applications, and, in general, it could be solved either by sending personalized HTML to per-user channels or by enhancing incoming HTML client-side. I prefer the second option, so let's implement it.

To pass the information about the current user to JavaScript, I use meta tags:

```erb
<!-- layouts/application.html.erb -->
<head>
  <% if logged_in? %>
    <meta name="current-user-name" content="<%= current_user.name %>" data-turbo-track="reload">
    <meta name="current-user-id" content="<%= current_user.id %>" data-turbo-track="reload">
  <% end %>
  <!-- ... -->
</head>
```

And a small JS helper to access these values:

```js
let user;

export const currentUser = () => {
  if (user) return user;

  const id = getMeta("id");
  const name = getMeta("name");

  user = { id, name };
  return user;
};

function getMeta(name) {
  const element = document.head.querySelector(
    `meta[name='current-user-${name}']`
  );
  if (element) {
    return element.getAttribute("content");
  }
}
```

To broadcast chat messages, we'll use a `Turbo::StreamChannel`:

```ruby
def create
  Turbo::StreamsChannel.broadcast_append_to(
    workspace,
    target: ActionView::RecordIdentifier.dom_id(workspace, :chat_messages),
    partial: "chats/message",
    locals: { message: params[:message], name: current_user.name, user_id: current_user.id }
  )
  # ...
end
```

Here is the original `chat/message` template:

```html

  <%= message %>
  <%= name %>

```

And the pre-existing JS code that applies different styling depending on the current user (that we will take out very soon):

```js
// Don't get attached to this
appendMessage(html, mine) {
  this.messagesTarget.insertAdjacentHTML("beforeend", html);
  const el = this.messagesTarget.lastElementChild;
  el.classList.add(mine ? "mine" : "theirs");

  if (mine) {
    const authorElement = el.querySelector('[data-role="author"]');
    if (authorElement) authorElement.innerText = "You";
  }
}
```

Now, when Turbo is responsible for updating HTML, we need to do things differently. Of course, the `useMutation` trick could be used here as well. And that's probably what I would do in the _real_ project. However, my goal today is to demonstrate different ways to solve problems.

Remember, we've been talking about Custom Elements? (Yeah, that was several pages ago, sorry, this has turned out to be a v-e-e-ry long read.) It's the Web API that powers Turbo. Why don't we use that!

Let me first share an _updated_ HTML template:

```html
<any-chat-message class="chat--msg" data-author-id="<%= user_id %>>
  <%= message %>
  <%= name %>
</any-chat-message>
```

We only added the `data-author-id` attribute and replaced a `` with our custom tag—`<any-chat-message>`.

Now let's register the custom element:

```js
import { currentUser } from "../utils/current_user";

// This is how you create custom HTML elements with a modern API
export class ChatMessageElement extends HTMLElement {
  connectedCallback() {
    const mine = currentUser().id == this.dataset.authorId;

    this.classList.add(mine ? "mine" : "theirs");

    const authorElement = this.querySelector('[data-role="author"]');

    if (authorElement && mine) authorElement.innerText = "You";
  }
}

customElements.define("any-chat-message", ChatMessageElement);
```

That's it! Now when a new `<any-chat-message>` element is added on a page, it automatically updates itself if the message came from the current user. And we don't even need Stimulus for that!

You can find the full source code from this article in [this PR][hotwire-pr].

So, does Reactive Rails With Zero JavaScript exist after all? Not really. We removed a lot of JS code but eventually had to replace it with something new. This new code is different from what we had before: it's more, I'd say, _utilitarian_. It's also more advanced and requires a good knowledge of both JavaScript and the latest browser APIs, which is definitely a trade-off to consider.

P.S. I also have a [similar PR][cable-ready-pr] for CableReady and StimulusReflex. You can compare it with the Hotwire one and share your opinions with us on [Twitter](https://twitter.com/evilmartians).

---

[Drop us a line](https://evilmartians.com/contact-us) if you want to enlist Martian backend (or frontend) experts to enhance your digital product.

[hotwire]: https://hotwire.dev
[railsconf-program]: https://railsconf.com/program
[stimulusreflex]: https://docs.stimulusreflex.com
[anycable-demo]: https://github.com/anycable/anycable_rails_demo
[turbolinks]: https://github.com/turbolinks/turbolinks
[stimulus]: https://stimulus.hotwire.dev
[mutation observer]: https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
[turbo]: https://turbo.hotwire.dev
[list-controller-original]: https://github.com/anycable/anycable_rails_demo/blob/fdb1353b3fa4aae2598b5eaceba838b73d09254e/frontend/controllers/list_controller.js
[form-request-submit-polyfill]: https://github.com/javan/form-request-submit-polyfill
[frames-commit]: https://github.com/anycable/anycable_rails_demo/pull/16/commits/0e54fb14592aa5313023b64487a9561ac60562f2
[turbo-frames-target-docs]: https://turbo.hotwired.dev/handbook/frames#targeting-navigation-into-or-out-of-a-frame
[turbo-frames]: https://turbo.hotwired.dev/handbook/frames
[turbo-streams]: https://turbo.hotwired.dev/handbook/streams
[stream_element.ts]: https://github.com/hotwired/turbo/blob/main/src/elements/stream_element.ts
[turbo-streams-mime-type-docs]: https://turbo.hotwired.dev/handbook/streams#streaming-from-http-responses
[stream_observer.ts]: https://github.com/hotwired/turbo/blob/8bce5f17cd697716600d3b34836365ebcdc04b3f/src/observers/stream_observer.ts#L50-L55
[stimulusreflex]: https://stimulusreflex.com/
[cableready]: https://cableready.stimulusreflex.com/
[stimulus-use]: https://github.com/stimulus-use/stimulus-use
[usemutation]: https://github.com/stimulus-use/stimulus-use/blob/master/docs/use-mutation.md
[hotwire-pr]: https://github.com/anycable/anycable_rails_demo/pull/16
[cable-ready-pr]: https://github.com/anycable/anycable_rails_demo/pull/12

---

This article was written by [Evil Martians](https://evilmartians.com), a product development consultancy trusted by teams from early-stage startups to public companies. If you're working through a hard problem, [we can help](https://evilmartians.com/contact-us)
