TurboMount is a simple library that allows you to add highly interactive components from React, Vue, Svelte, and other frameworks to your Hotwire application.
To install Turbo Mount, add the following line to your Gemfile and run bundle install:
gem "turbo-mount"
Automatic Installation
Run the following command to install the necessary files:
bin/rails generate turbo_mount:install
This will add turbo-mount package and framework dependencies to your package.json or importmap.rb, and create the Turbo Mount initialization file.
Manual Installation
You can also install the necessary JavaScript files manually.
If your project utilizes build tools such as Vite, also install the turbo-mount package:
npm install turbo-mount
# or with yarn
yarn add turbo-mount
# and the desired framework
npm install react react-dom
# or
npm install vue
# or
npm install svelte
This ensures that turbo-mount and its plugins are available in your application.
Also pin the desired framework:
bin/importmap pin react react-dom react-dom/client
# or
bin/importmap pin vue
# or
bin/importmap pin svelte
Note: Importmap-only mode is quite limited in terms of JavaScript dependencies. If you're using a more complex setup, consider using a bundler like Vite.
Usage
Initialization
To begin using TurboMount, start by initializing the library and registering the components you intend to use. Here's how to set it up with a React plugin:
If you prefer not to specify the application explicitly, TurboMount can automatically detect or initialize it. Turbo Mount uses the window.Stimulus if available; otherwise, it initializes a new Stimulus application.
Make sure your application.js is importing turbo-mount.js:
TurboMount includes a registerComponents functions that automates the loading of components. registerComponents also accepts an optional controllers property to autoload customized controllers.
The registerComponents helpers search for controllers in the following paths:
controllers/turbo-mount/${controllerName}
controllers/turbo-mount-${controllerName}
Components in Nested Directories
Turbo Mount supports components located in nested directories. For example, if you have a component structure like:
ESBuild helper requires the esbuild-rails package to load components and controllers. Read the ESBuild Rails README for more information on how to set it up.
To specify a non-root mount target, use the data-<%= controller_name %>-target="mount" attribute:
<%= turbo_mount("HexColorPicker", props: {color: "#430"}) do |controller_name| %>
<h3>Color picker</h3>
<div data-<%= controller_name %>-target="mount"></div>
<% end %>
License
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that turbo-mount demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.It has 1 open source maintainer collaborating on the project.
Package last updated on 11 Jun 2025
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.