sahat / megaboilerplate

Handcrafted starter projects, optimized for simplicity and ease of use.
MIT License
3.83k stars 257 forks source link

Universal implementation with React and Express? #141

Closed SOSANA closed 8 years ago

SOSANA commented 8 years ago

@sahat I didn't see any open or closed issues regarding this so thought I would ask.

Are you planning an implementation for universal react and express?

Thanks for this project!

sahat commented 8 years ago

@SOSANA Are you referring to server-side rendering with React?

SOSANA commented 8 years ago

@sahat yes I was referring to server-side rendering

I use to use puphpet, not sure if you heard of it and was thinking why isn't there a setup like this outside of php (I would strip php out for node.js), than this evening I started going through your repo's to see what you been up too and and stumbled upon this, crazy!

sahat commented 8 years ago

@SOSANA React generator already comes with server-side rendering by default. https://github.com/sahat/megaboilerplate/blob/master/examples/express-nunjucks-postcss-unstyled-react-webpack-mocha-sqlite-twitter/server.js#L117-L130

It's a little complicated because of authentication, but other than that, it's the same code from react-router's guide on server-side rendering.

SOSANA commented 8 years ago

@sahat I was thinking down the lines of templating using react.js and having option to select it as well, than first inital render done on server, than client takes over after that. Appears at just glancing all routes being handled serverside, but will look into it deeper as I have never used nunjucks before,

Is this only for sqlite?

SOSANA commented 8 years ago

@sahat are you more in favor of nun,jucks? First FAQ on nunjucks: Can I use nunjucks in node and the browser/client-side? Yes

Would you entertain react.js at this point for templating,and having an option for it?

SOSANA commented 8 years ago

Thanks @sahat

sahat commented 8 years ago

@SOSANA Template engine choice will go away soon for React. There is little reason to use it since it's just as easy to render "index.html" directly inside App.js component.