News for hackers. Stuff that matters.
Re:API server and a static front end – the future? by eloff on Saturday October 03, 2015 @05:19PM (#10325428)
What idiot downvoted this? This is the solution for companies using single page sites. You render the page server side using some headless browser and serve that on the first load (or always for search engine spiders, or people with JavaScript disabled.) That way you don't suffer the latency penalty on the first load and subsequent loads work as usual with a single page app. I'm pretty sure I read that twitter does this, but it might be some other big player.
Re:API server and a static front end – the future? by mmahemoff on Saturday October 03, 2015 @05:31PM (#10325474)
It's a fine architecture, true. Maybe you're thinking of AirBNB, they popularised this "holy grail" model (http://www.oreilly.com/pub/e/3009) since around 2012.

Twitter did have to backtrack from the #newtwitter pure client-side model. Serving a 140-character string shouldn't require a 1+ MB payload. So maybe they server-generate their pages this way too now.

Re:API server and a static front end – the future? by sanderjd on Saturday October 03, 2015 @05:30PM (#10325467)
It is definitely the solution, but I've yet to find the setup that makes it cheap and easy to do. Links welcome!
Re:API server and a static front end – the future? by Wintamute on Sunday October 04, 2015 @10:35AM (#10327623)
React + some sort sort of library to handle app state (Redux is recommended). You gain a modern componentised frontend app and the ability to render it server side. Server rendering of a React app is pretty simple, of order maybe a 100 lines of code or so. And that includes populating the server rendered pages from the same API as the frontend uses. Redux docs may be a decent place to start:

http://rackt.github.io/redux/docs/recipes/ServerRendering.ht...

Re:API server and a static front end – the future? by firasd on Saturday October 03, 2015 @05:41PM (#10325504)
React will render HTML on the server side using the same code and data structures you use for dynamic components on the client side. https://facebook.github.io/react/
Re:API server and a static front end – the future? by GordyMD on Saturday October 03, 2015 @05:58PM (#10325545)
To demonstrate this point for those not familiar. Here is an example of using React + Redux on the server to render with an initial state.

https://github.com/GordyD/3ree/blob/master/server/universalA...