Installation and Configuration

How to install and configure both the Ruby GEM and NPM package

01

Add the GEM to your Gemfile

$ command line
bundle add turbo_boost-commands

The command above adds this to the Gemfile.

Gemfile
gem "turbo_boost-commands", "~> 0.3.2"
02

Add the NPM packages to your package.json file

$ command line
npm install @turbo-boost/streams@$(bundle show turbo_boost-streams | ruby -ne 'puts $_.split(/-/).last')
npm install @turbo-boost/commands@$(bundle show turbo_boost-commands | ruby -ne 'puts $_.split(/-/).last')

The command above adds this to package.json.

package.json
{
  "dependencies": {
    "@turbo-boost/streams": "^0.1.11",
    "@turbo-boost/commands": "^0.3.2"
  }
}
$ command line
bin/importmap pin add @turbo-boost/streams@$(bundle show turbo_boost-streams | ruby -ne 'puts $_.split(/-/).last')
bin/importmap pin @turbo-boost/commands@$(bundle show turbo_boost-commands | ruby -ne 'puts $_.split(/-/).last')

The command above adds this to importmap.rb.

config/importmap.rb
pin "@turbo-boost/streams", to: "https://ga.jspm.io/npm:@turbo-boost/streams@0.1.11/app/javascript/turbo_boost-streams.js"
pin "@turbo-boost/commands", to: "https://ga.jspm.io/npm:@turbo-boost/commands@0.3.2/app/javascript/turbo_boost-commands.js"
03

Configure your JavaScript app

app/javascript/application.js
import '@hotwired/turbo-rails'
import '@turbo-boost/streams'  // <-- add this line
import '@turbo-boost/commands' // <-- add this line

// set the log level [optional]
//
//   - unknown (default)
//   - debug
//   - info
//   - warn
//   - error
//
TurboBoost.Commands.logger.level = 'debug' // <-- add this line [optional]

That's it! You're ready to start using TurboBoost Commands. 🙌

Was this helpful?

I hope TurboBoost helps you get better at Hotwire while teaching you some cool new tricks... because this stuff is fun and addictive. Check out the test/dummy app on GitHub to see how this site was made, and please consider supporting my efforts.

Sponsor TurboBoost