Nicholas Haley Nicholas Haley - 19 days ago 9
React JSX Question

Getting started with React and Rails

I have started a new project in which I would like to use React and Rails. This project is on the small side and will require some basic interactive UI, hence React. As far as I know there are two ways I could get started with this:


  • Using the react-rails gem and use the built in view helper

  • Create a Rails API and React/Flux frontend app



I have a few questions however. In no particular order:


  • React-rails seems like the simpler solution, but what drawbacks would I be facing?

  • I come from a Rails and Ember background so the Rails API + React FE solution makes architectural sense to me. But with the react-rails gem I'm confused on how some things should be done. Primarily, how do I handle routing? I suppose I won't have access to any react route helpers and will need to pass paths into the react components as props?



Thanks in advance!

Answer

For a small project React-Rails, https://github.com/reactjs/react-rails, is great I have used it in production the last year on 2 sites that get about hundred thousand visitors a month and I haven't had any issues.

That said if you want to use Redux, React-Router or Flux don't use React-Rails go the API route.

My rule is if you are just using React components then use React-Rails.

If you are doing a Redux, Flux app then just make a frontend app.