Node.js rendering engine

Current version: 19.x

The Node.js rendering engine uses a node.js instance running on your Sitecore Content Management (CM) server to render your applications built with the JavaScript Rendering SDK (JSS). If using integrated mode in production, the node.js instance must run on the Content Delivery (CD) server.

Note

The Node.js rendering engine is not usable with JSS for Next.js or ASP.NET Rendering SDK applications.

Architectural overview

The ASP.NET and the Sitecore MVC infrastructure are extensible and allow for custom JavaScript renderers plugging in.

When the browser sends a page request, the JavaScript renderers hand off the JavaScript bundle and Layout Service JSON-formatted data to node.js through the ASP.NET NodeServices. Node.js returns a response containing the HTML string.

Server-side rendering request-response flow with the Node.js rendering engine

The page-level items that correspond to the route are expected to have conventional presentation details set on them:

Presentation details on page-level items

Using a layout based on the /sitecore/templates/Foundation/JavaScript Services/JSS Layout template, in the previous image, JSS App triggers rendering by Headless Services using the rendering engine configured for the JSS application. The layouts, in this case, serve only as indicators and point at empty Razor views. The WelcomeRendering is a real Sitecore rendering item of the type React JavaScript Rendering , defined under /sitecore/layout/renderings.

In their server bundle, the JSS applications export and invoke a renderView function that consumes the response to produce the static rendering of the application. Data passed into this function is double encoded to preserve JSON formatting and must be parsed with JSON.parse() before use.

Pros and cons of the Node.js rendering engine

Pros

  • It is simple to set up. Install node.js on the Sitecore server and add the node executable to the PATH.

  • You do not have to manage node.js instances manually.

  • Built-in pooling.

Cons

  • You have limited customization options of node.js startup, profiling, debugging.

  • You have limited control over pooling/clustering.

  • You need to install node.js on Sitecore servers.

  • You must deploy JSS app artifacts to the Sitecore server.

  • Not usable with Next.js or ASP.NET Core

Do you have some feedback for us?

If you have suggestions for improving this article,