# Migrating from UJS to Turbo

**URL:** <https://discuss.hotwired.dev/t/migrating-from-ujs-to-turbo/1942>\
**Category:** General\
**Created:** [January 10, 2021, 9:26pm UTC](https://discuss.hotwired.dev/t/migrating-from-ujs-to-turbo/1942 "2021-01-10T21:26:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![angilly](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/angilly/32/1419_2.png) [@angilly](https://discuss.hotwired.dev/u/angilly)\
**Post date:** [January 10, 2021, 9:26pm UTC](https://discuss.hotwired.dev/t/migrating-from-ujs-to-turbo/1942/1 "2021-01-10T21:26:22Z")

</div>

Hey guys,

I’m really impressed with Hotwire. I have a 5 year old Rails app that has come up through the ranks from Ruby 2.1/Rails 3 back in 2015 to 2.6.5/6.1 now. We also use Mongoid, and we’ve never used turbolinks. Given those things, I was pleasantly very surprised that I was able to get the demo chat app working so quickly.

But then I saw that Turbo requires turning off UJS. That blew me away. UJS is huge part of my app. Turning it off breaks over half the app. Not being able to use UJS feels like a complete dealbreaker. I’ve looked around a bunch and I don’t see anybody else balking at this, so I’m wondering if either:

1. When I wasn’t looking, UJS fell out of favor and I should have migrated off it a while ago
2. It’s super easy to migrate from UJS to Turbo but I just haven’t RTFM’d enough
3. It’s simply expected that migrating from UJS to Turbo is just a Very Hard Thing

To be clear, if the answer 3, then cool so be it. Maybe I’ll still invest the time in playing around with it, but before I do that, I wanted to see if there was something subtle or obvious I was missing 🙂

Thx!

---

<div class="post-metadata">

**Author:** ![SimonBo](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/simonbo/32/1420_2.png) [@SimonBo](https://discuss.hotwired.dev/u/SimonBo)\
**Post date:** [January 12, 2021, 9:09am UTC](https://discuss.hotwired.dev/t/migrating-from-ujs-to-turbo/1942/2 "2021-01-12T09:09:13Z")

</div>

Hmm where does it say that you have to turn off UJS? I just migrated an app from turbolinks to turbo and UJS still works ok.

---

<div class="post-metadata">

**Author:** ![angilly](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/angilly/32/1419_2.png) [@angilly](https://discuss.hotwired.dev/u/angilly)\
**Post date:** [January 12, 2021, 5:56pm UTC](https://discuss.hotwired.dev/t/migrating-from-ujs-to-turbo/1942/3 "2021-01-12T17:56:12Z")

</div>

It says it on this page: [GitHub - hotwired/turbo-rails: Use Turbo in your Ruby on Rails app](https://github.com/hotwired/turbo-rails#compatibility-with-rails-ujs)

> Rails UJS includes helpers for sending links and forms over XMLHttpRequest, so you can respond with Ajax. Turbo supersedes this functionality, so you should ensure that you’re either running Rails 6.1 with the defaults that turn this off for forms, or that you add `config.action_view.form_with_generates_remote_forms = false` to your `config/application.rb` .
> 
> Note that the helpers that turn `link_to` into remote invocations will _not_ currently work with Turbo. Links that have been made remote will not stick within frames nor will they allow you to respond with turbo stream actions. The recommendation is to replace these links with styled `button_to` , so you’ll flow through a regular form, and you’ll be better off with a11y compliance.
> 
> You can still use the `data-confirm` and `data-disable-with` .

Do you have any `data-remote: true` forms in your app?

---

<div class="post-metadata">

**Author:** ![SimonBo](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/simonbo/32/1420_2.png) [@SimonBo](https://discuss.hotwired.dev/u/SimonBo)\
**Post date:** [January 12, 2021, 7:22pm UTC](https://discuss.hotwired.dev/t/migrating-from-ujs-to-turbo/1942/4 "2021-01-12T19:22:10Z")

</div>

Had a ton of them. They should still work after installing turbo, the biggest issue i had was that the redirects stopped working for turbolinks form submits. I made all forms non remote and that was mostly enough. If you have some .js.erb responses then they would need to be migrated to turbo OR just continue using remote forms.

---

<div class="post-metadata">

**Author:** ![angilly](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/angilly/32/1419_2.png) [@angilly](https://discuss.hotwired.dev/u/angilly)\
**Post date:** [January 20, 2021, 3:34pm UTC](https://discuss.hotwired.dev/t/migrating-from-ujs-to-turbo/1942/5 "2021-01-20T15:34:42Z")

</div>

Hmm ok thanks for the response, Simon. Will noodle on it over here. Have a good one.

---

<div class="post-metadata">

**Author:** ![archonic](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/archonic/32/2294_2.png) [@archonic](https://discuss.hotwired.dev/u/archonic)\
**Post date:** [October 23, 2021, 12:14am UTC](https://discuss.hotwired.dev/t/migrating-from-ujs-to-turbo/1942/6 "2021-10-23T00:14:22Z")

</div>

My upgrade to Turbo from Turbolinks and UJS started with removing UJS because I had read and heard that the two are not compatible. They submit forms under a different content\_type and I figured if Turbo was to replace UJS (another thing I’ve been reading) then I might as well rip it out now.

I found that Turbo, despite much fiddling and googling just wasn’t able to render a redirect response from a form. I tried everything. I reintroduced UJS after trying everything else and installed this shim: [turbolinks-rails/redirection.rb at master · turbolinks/turbolinks-rails · GitHub](https://github.com/turbolinks/turbolinks-rails/blob/master/lib/turbolinks/redirection.rb)

I now have the right script response and content\_type, but the JS just… isn’t executing. I can copy and paste the response body into the console and it does exactly what I want it to - it just doesn’t execute it upon response.

So if you’ve been having issues upgrading to Turbo, you’re not crazy. I’ve found it to be far from the drop-in replacement that some have said it is.
