Creating a React Application with Headless Drupal 8

2017-03-28

Troy Kearney

Creating a React Application with Headless Drupal 8

Tutorial on setting up Drupal 8 with RESTful services and integrating with a React frontend.

Overview:

  • Setting up Drupal to enable RESTful Services
  • Implementing React with Drupal
    • Get a list of articles
    • Add a new article

For this tutorial I will go over how to setup a Drupal 8 site with RESTful services as well as setting up a simple React application which will retrieve a list of Articles and allow for the creation of articles for logged in users with the proper credentials.

Before working with React we will need to configure Drupal to provide us with some RESTful services.

The first step you will need to take is downloading and enabling the following modules: RESTful Web Services (rest), Serialization (serialization), and RESTUI (restui).

To be able to get all nodes on the front page, make a new display for the Frontpage view. The type of display should be REST export. In the Serialization settings set the Accepted request format to json. Give this new display a path of /node/rest

The full code for this tutorial is available here