Simple server rendering

There have been some people asking for server rendering with node.js, but what if instead we did server rendering agnostic of the backend?

The idea is to create a UMD build which exports one function. The function takes some arguments and returns a renderToString result. The generated version of this entry point would be very simple, but it could be extended by the user to support react-router, redux, etc. They can add these things without ejecting, which is nice.

module.exports = (options) => ReactDOMServer.renderToString(<App data={} />);

This bundle could be used in node.js with a simple require(), or loaded into phpv8 or similar and expose a global.

Building this bundle would be a separate build task with an optional watch mode. For node users, nodemon would pick up the bundle change and restart the server.

1 thought on “Simple server rendering

Comments are closed.