TreeviewCopyright © aleen42 all right reserved, powered by aleen42

Server-side Environment Back

One of the great things about React is that it doesn't require the DOM as a dependency, which means it is possible to render a React application on the server and send the HTML markup down to the client.


Node.js is a popular JavaScript runtime that comes with an extensive core library and support for installing packages from npm to expand on the basic functionality.

If you use JSX, you may want to pre-compile your components. Alternatively you may want to consider using Babel's require hook or babel-node.


Some versions of Node.js have an Object.assign implementation that does not preserve key order. This can cause errors when validating the markup, creating a warning that says "React attempted to reuse markup in a container but the checksum was invalid". If you run into this issue, you can override Object.assign to use a polyfill that preserves key order. For more details, see Issue #6451.


Support for server-side component rendering and JSX compilation (via Babel) in a .NET Framework / ASP.NET environment is provided through our ReactJS.NET project.


Nashorn is a lightweight high-performance JavaScript runtime that runs within the JVM. React should run out of the box in Java 8+.


import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class ReactRender
    public static void main(String[] args) throws ScriptException, IOException {
        ScriptEngine nashorn = new ScriptEngineManager().getEngineByName("nashorn");

        // These files can be downloaded as a part of the starter kit
        // from
        nashorn.eval(new FileReader("path/to/react.js"));
        nashorn.eval(new FileReader("path/to/react-dom-server.js"));

            "ReactDOMServer.renderToString(" +
            "React.createElement('div', null, 'Hello World!')" +

If your application uses npm packages, or you want to transform JSX in Nashorn, you will need to do some additional environment setup. The following resources may be helpful in getting you started:


Using Babel within Nashorn will require Java 8u72+, as update 72 fixed JDK-8135190.

Empty Comments
Sign in GitHub

As the plugin is integrated with a code management system like GitLab or GitHub, you may have to auth with your account before leaving comments around this article.

Notice: This plugin has used Cookie to store your token with an expiration.