
You need to first git commit your files before running the generator, or else it will generate an error.

Install React on Rails: rails generate react_on_rails:install or rails generate react_on_rails:install -redux. # Newer versions of Rails create the git repo by default. # Here are git commands to make a new git repo and commit everything. Run bundle and commit the git repository (or rails generate will not work properly) bundle Please use the latest version to ensure you get all the security patches and the best support. Note: Latest released React On Rails version is considered stable. Note: if you are installing React On Rails in an existing app or an app that uses Rails pre 5.1.3 ( not for Rails > 5.2), you will need to run these two commands as well: bundle exec rails webpacker:installīundle exec rails webpacker:install:reactĪdd the React On Rails gem to your Gemfile: gem 'react_on_rails', '11.2.1' # prefer exact gem version to match npm version Rails new test-react-on-rails -webpack=react If you are using an older version of Rails, you'll need to install webpacker with react per the instructions here. Then we need to create a fresh Rails application with webpacker react support as following.įirst be sure to run rails -v and check you are using Rails 5.1.3 or above. Gem install foreman # download and install Foreman Gem install rails # download and install latest stable Rails Rvm use 2.5.0 -default # use it and make it default Rvm install 2.5.0 # download and install latest stable Ruby (update to exact version) Nvm alias default node # make it default versionīrew install yarn # you can use other installer if desired nvm install node # download and install latest stable Node Rails can be installed as an ordinary gem. I recommend rvm and nvm to install Ruby and Node, and brew to install yarn. This includes the basics for Rails 5.x and node version 6+. Trying out React on Rails is super easy, so long as you have the basic prerequisites.

react_on_rails 6.6.0 and greater uses yarn. Note: some of the screen images below show the "npm" command. Source code for this app in PR, using the -redux option and for Heroku.īy the time you read this, the latest may have changed.It is updated to 11.2.1.Īfter finishing this tutorial you will get an application that can do the following (live on Heroku): This tutorial guides you through setting up a new or existing Rails app with React on Rails, demonstrating Rails + React + Redux + Server Rendering.

Hot Reloading of Assets For Rails Development for Asset Pipeline Webpack, the Asset Pipeline, and Using Assets w/ React Setting up Hot Reloading during Rails Development, API docs Rails View Rendering from Inline JavaScriptĬonverting a Rails 5 API only app to a Rails appĪngularJS Integration and Migration to React on Rails React on Rails Internationalization (I18n, localization) React on Rails Basic Installation TutorialĬaching and Performance: React on Rails Pro
