Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should we use Rails routes or React routers

I am new with React and today I was working on react-routers. I am not clear which routes to use. My choices are Rails routing or React router. What are the difference between these?

like image 269
Vijay Chouhan Avatar asked Dec 04 '25 09:12

Vijay Chouhan


1 Answers

React should be used for rendering and Rails should be used for the API. Each react app should have its own server-rendered path, with calls to a rails API on the backend. The API should definitely be routed with rails, but only pass back the data you need to the react app. Rails 5 has ApiController you can use for your controller superclass. TL;DR - React is frontend, rails API on the backend.

Also, you should really determine if you need something so heavyweight on the backend. Some lighter ruby alternatives are Sinatra and Padrino.

like image 180
Skaman Sam Avatar answered Dec 06 '25 23:12

Skaman Sam