Nicholas Haley
Nicholas Haley

Reputation: 4014

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:

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

Thanks in advance!

Upvotes: 2

Views: 487

Answers (2)

nzajt
nzajt

Reputation: 1985

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.

Upvotes: 2

David Gilbertson
David Gilbertson

Reputation: 4853

It depends on how much your server is doing and also your team. If you have a lot of business logic that you want to keep in Rails, then you may want to have that logic running on a dedicated Rails server and expose as APIs.

You can then have a NodeJS server that does nothing but fetch data from APIs and render React to send to the users. The only interaction between react and rails is via the APIs as JSON. This basic setup will scale really well and is a pretty simple mental model.

If the project gets bigger, this means you can have JS-only devs work in JS only and Rails devs work in Rails only. Plus if you want to move away from Rails or React later, there's no added complexity there.

OR

If all your devs are React+Rails and the project is a bit small for multiple servers, then I think using react-rails to serve up your pages is a fine solution.

Upvotes: 1

Related Questions