After being proposed initially by Dries Buytaert in 2017 at DrupalCon, Vienna, community members now estimate that 2020 will be the year when Drupal officially adds React as a theme option to the core CMS distribution. Drupal 7 primarily uses PHPTemplate as the theme engine, while Drupal 8 implements the Twig & Symfony2 frameworks. Although both professionally licensed and open source themes for Drupal 8 have been successful on Twig/Symfony2, there is a growing development sector advancing decoupled or “headless” methodologies based on Node.js. What is not clear is the level of support required for Node.js in the future of retail web hosting for Drupal, with some sites opting for a progressively decoupled or fully decoupled approach as alternatives to monolithic traditional installations. There are currently different installation requirements for running Drupal 8 on NGINX vs. Apache, whereas Node.js is equally compatible with both server formats for building new decoupled Drupal solutions.
“Most people seem to want a way to compose interfaces and interactions with reusable components (e.g. libraries like React, Vue, Polymer, and Glimmer) rather than use a framework with a heavy focus on MV* workflows (e.g. frameworks like Angular and Ember).”
Decoupled Drupal: Using React, Angular, Vue, Ember, & Gatsby for Theme Development
RESTful APIs & Drupal 8: Use React vs. Conventional MVC Frameworks
“In this hands-on session, you will learn how to build a decoupled website using React ecosystem on the front-end and Drupal 8 as the content management system and a data source.” (DrupalCon Dublin 2016)
- How to configure Drupal to expose RESTful resources using Drupal 8
- Enable CORS support for the domains/port running our React application
- Authenticate requests using JWT
- Consume data on front-end using Redux store
- Pass data from Redux store React components
Pantheon Decoupled CMS: ‘Drupal and WordPress are both traditionally “monolithic” CMSs, with presentation baked in via the theme. However, due to the need for more flexibility and freedom, many developers have begun decoupling the CMS, using it for content management, editorial, and administrative tools, while implementing a separate frontend component dedicated to the user experience which communicates with the CMS via a web API.’ Learn More About Decoupled CMS Architecture.
- Introduction to React and Drupal
- 8 Things to Know About React for Drupal Devs
- An Introduction to Drupal for React Developers
Consider the different web hosting requirements for Drupal 8 + Node.js and the advantages of React in core. These Drupal 8 modules provide integration functionality:
If the dependency for React in Drupal 8 includes NPM, all shared web hosts may not support it. Learn more about NPM & Drupal 8 integration:
NPM requires Node.js to be installed on the web server, but is not part of the Node.js package. Many shared Linux web hosts do not support this at the present time, requiring a VPS, Cloud, or Dedicated hosting plan. Some shared Linux web hosts now support Node.js but this is not common on most platforms, i.e. Pantheon with specific Node.js environments. Otherwise Yarn needs to be installed on CentOS with Drush which is also not common or default among most cPanel web hosting companies.
NPM Command Line Tools: “Use npm to install, share, and distribute code; manage dependencies in your projects; and share & receive feedback with others. The npm registry hosts the world’s largest collection of free, reusable code. Libraries like jQuery, Bootstrap, React, and Angular, and components from frameworks such as Ember. Packages for mobile, IoT, front end, back end, robotics… everything you need to start building amazing things. Assemble packages like building blocks to quickly develop awesome new projects.”Learn More About NPM Package Manager for Node.js.
Outlook: React Not Likely to Replace Drupal 8 Themes Based on PHP & Twig
Although adoption of React in Drupal core will potentially open up a new sector of theme possibilities, it is not likely to replace the PHP options powered by Twig/Symfony2 in popular usage. More shared Linux web hosting companies are adding support for Node.js, but the majority use it as an upsell to a VPS plan. If user demand on cPanel hosting increases for Node.js support, the companies will likely add the functionality to their web stack. Companies like Pantheon are already offering customized Node.js platform support for Drupal 8 hosting, and Acquia now has this option on their cloud as well. These managed cloud plans are excellent for hosting Drupal 8 websites with Node.js in a high performance environment for production.