Simple POC to test React server side rendering capabilities and code sharing.
I've used the node-jsx module to seamlessly require jsx
modules.
var home = require('./app/home.jsx');
Start the server
npm start
Run the (stupid) benchmark
npm test
It is possible to use express-react-views to handle the JSX as views (althogh it still have the same problem of requiring server restart to reflect changes in the views code). Might be an option, although it limits its use as real components in the client.
- Any change in the code of the views/components require a server restart to be applied. Something that can be easily resolved using something like supervisor.
- It is probably going to be impossible to have a React component using a underlying jQuery component in this situation, since we don't have the DOM in the server.
- You change the common pattern of requiring a module without an extension (you need to add
jsx
).