github << rails / stimulus / hotwire

Rails Importmaps (Managing JS Dependencies) October 15, 2025

To add an external javascript library (e.g. react.js) to a Rails app that uses importmap:

$ bin/importmap pin react

To remove:

$ bin/importmap unpin react

Or, you can open config/importmap.rb and add libraries manually.

pin "react", to: "react-cdn-url-link"

All dependencies imported through importmap are loaded in the html head tag via the javascript_importmap_tags.