Have you ever wonder that how to create React with Rails application or You want to integrate React views in your existing Rails application? Since React is gaining an attention, many of Ruby on Rails developers are looking for the answers. Here, I am going to show you three most popular ways for creating React with Rails application. Apart from these three ways, there are many other possible ways that you can achieve this target. We will not discuss in depth about the approaches in this tutorial but our target is to get idea about three most popular approaches for the react with rails application. So, let’s jump into the story.
1. react-rails Gem
This project is gain a lots of attention from Rails developer. It gained more stars then react_on_rails gem because of it’s simplicity to use in Rails application. It uses the default Rails asset management and automatically transforms JSX into the asset pipeline using the Ruby Babel transpiler. I have covered full tutorial how to integrate rails application with react using react-rails gem.
2. react_on_rails Gem
This is another way to integrate React with Rails by just adding a Gem to our Rails application. This is also very popular among the Rails developers. The key difference between
react_on_rails gem and
npm. This will gives us extra flexibility at cost of installing some extra libraries. I am going to create a demo for that soon. Subscribe here for latest update.
3. React Front end and Rails API
Third approach is include separate View(fronted) in react and API (back end) in the rails application. These two component may be resides in single application directory or they be totally separate app. This approach will need some extra efforts to create two different apps but certainly it will be paid off. APIs will helps us to build mobile applications using the same code base. Also, react app will be running in more compatible java script environment(i.e. node and express) that will help you to use latest front end tools easily.
With my experience in the service industries, I believe the third approach discussed above is the most case asked by the clients. So I am going to cover total tutorial for this point in my next article. Subscribe here to get latest update.
Call To Action
Do you want to be awesome React with Rails developer? Subscribe my weekly tutorials by clicking over here. This will make you really awesome React Developer.
Mayur is a Chief Technical Architect in his organisation. He has more than three years of experience in designing and building scale able applications using different technologies.