Menu

React, etc. Tech Stack

React, Flux, GraphQL, Hack, HHVM...? All of this and more!

Rendering React.js in Twig (for Drupal 8)

Server side rendering and isomorphic JavaScript is somewhat of a hyped topic these days. Mostly the whole stack is built with JavaScript, from the server running Node.js to the client using a framework/library such as React.

This is a natural thing, but with Content Management Systems built with LAMP (PHP, Linux, Apache, MySQL) still rule the web, you'll likely want to bridge these in some cases. Symfony is a big topic in the LAMP CMS circles today.

With Drupal 8, eZ Platform and others embracing it, it's a common thing that unifies PHP CMS developers like nothing before it (counting out PHP itself).

There are multiple different options of embracing Isomorphic JavaScript in Drupal, but one stands out as a universal option. Integrating the popular Twig templating engine together with Node.js for rendering of JavaScript. There is already a concept implementation, Twigriot, that enables rendering of Riot.js components in Twig.

This implementation is very generic regarding the underying system using Twig or the JavaScript library in use, so this article might as well be titled Rendering React.js Components in Drupal 8, instead of Twig and Riot.js.

Written by Jorgé on Saturday September 19, 2015

Permalink - Tags: react, isomorphic, javascript, drupal, twig

« Flow is a type checker for JavaScript, so what is it? - React.js and Flux demystified »