shade icon indicating copy to clipboard operation
shade copied to clipboard

Render DOM on the serverside

Open arianvp opened this issue 11 years ago • 2 comments

When you use React.renderComponentToString(component) in React you can prerender the DOM to html in such way that you can send the pre-rendered HTML to the client and then 'hook' to the pre-rendered DOM as if it was generated on the client itself.

You can even take this a step further with the ReactAsync package and do stuff like XHR on the serverside aswell and prerender those elements that depend on asynchronously loaded content into the DOM.

Example: https://github.com/andreypopp/react-quickstart

I was wondering if something like this would be worth exploring in shade. It would be extremely cool.

arianvp avatar Jul 16 '14 12:07 arianvp

You are right, this is a great feature of React and I'm definitely planning on taking a crack at it! One of the advantages of the tagless-final style is you can re-interpret the same expressions in different contexts-- I'm planning on making a "server side" context that takes your views and generates static content (possibly via blaze-html etc).

I didn't know about ReactAsync though. that's a cool idea and definitely worth looking into.

takeoutweight avatar Jul 20 '14 06:07 takeoutweight

My two cents:

ReactAsync is intended for the cases where it is extremely necessary to perform async state generation, and as the disclaimer says in the README, it is not something you should build apps off of.

L8D avatar Nov 03 '14 10:11 L8D