Rails 7 and React Install Guide

submited by
Style Pass
2022-01-20 20:30:10

I love Rails! I also really like React for complex, interactive components. I’ve found it very product to use Turbo and Stimulus (from Hotwire) with sprinkles of React.

With Rails 7, esbuild is now the default javascript tooling. In the past, I’ve used react-rails but their documentation is still aimed at webpacker based Rails projects. Thankfully, a kind soul found a working setup with esbuild. I took their working example repo and made this step by step guide.

Next, add ImportGlobPlugin() to the plugins array in your config object. It should look like this after plugins: [rails(), ImportGlobPlugin()],.

Leave a Comment