Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Isomorphic React + Flux + REST API

So, I've been fiddle:ing with some isomorphic React + Flux lately and have found some concepts quite confusing to be honest. I've been looking into best practices about how to structure isomorphic apps and are looking for advice.

Suppose you are creating a webapp as well as a mobile app backed by the same REST API. Do you bundle your REST API together with the webapp? I've seen people advocating both bundling and having a separate codebase for the REST API.

Any advice or suggested reading is appreciated!

like image 520
DrDumbom Avatar asked May 21 '15 19:05

DrDumbom


2 Answers

Fluxible (atleast from the examples) does advocate using the service layer inside the application calling it directly from the server and via xhr from the client without duplicating the code https://github.com/gpbl/isomorphic500/blob/master/src/app.js This is an example I followed religiously while building the isomorphic app

like image 169
Rajat banerjee Avatar answered Oct 21 '22 10:10

Rajat banerjee


The idea is very simple. Let's assume you have SPA and a backend wich provides REST API.

SPA (in browser) <====> Backend REST API

in isomorphic case, it is absolutely the same, except you will run your SPA on the server too.

So, it will work like that:

SPA (in browser) <====> Backend REST API
SPA (on server)  <====> Backend REST API

If you have a mobile app then it will be:

SPA (in browser) <====> Backend REST API
SPA (on server)  <====> Backend REST API
Mobile app       <====> Backend REST API

Here is a real isomorphic production application opened by us to the community - https://github.com/WebbyLab/itsquiz-wall . You can just clone it and run.

Here is my post which describes all the ideas behind the app in details.

like image 44
koorchik Avatar answered Oct 21 '22 09:10

koorchik