In recent years, more and more developers and website owners are losing their heads over the awesome concept of headless, or decoupled, Drupal. Among all Drupal releases, Drupal 8 is the best suited to headless architecture. This is due to its built-in web services which are named among the most trending achievements in Drupal’s evolution from D1 to D8. OK, we’ll now see what lies at the head of the “headless” approach and how it works in Drupal 8.
Headless or decoupled Drupal: let’s get acquainted
When introduced, a polite gentleman takes his hat off, but how should headless Drupal greet you — hopefully, not with his head in his hands?
Jokes aside, this term, a little bit scary and funny at the same time, usually makes your imagination picture “headlessness.” However, projects that are born from the decoupled approach can be amazing beyond any imagination.
The part users directly interact with is completely non-Drupal. They do not see the Drupal front-end theme (the so-called “head”), hence the term “headless.”
With the headless approach, you can do all this:
- output your Drupal website data to any application you need
- supercharge your Drupal site with exceptional qualities other systems offer (interactivity, ultraspeed and more)
- improve performance due to the fact that the front-end app is focused on its “duties”
- be free to use native tools and practices in front-end development
… and more!
Headless Drupal 8 and special decoupling opportunities
Considering the benefits, no wonder that “the best heads” of the Drupal community set up a major Drupal 8’s web service initiative (WSCCI) to make “the great eight” ready for the headless architecture out-of-box.
We are now happy to say that Drupal 8 has built-in web services designed to be the connecting link between Drupal and another system.
They help output Drupal’s data in JSON, HAL+JSON, XML or other non-HTML formats that are easy to “consume” by other apps. In this way, systems that are so different can communicate, cooperate, and bring out the best in each other.
When it comes to Drupal 8’s web services for decoupling purposes, you have a great choice of these. Usually, decoupling is associated with RESTful services (or those based on the REST architectural pattern). However, non-RESTful ones are gaining momentum.
Drupal 8’s powerful RESTful “team” includes the core players such as the Serialization, the RESTful Web services, the HAL, and the HTTP Basic Authentication (Basic Auth) modules. Their job is to provide a RESTful web API, serialize/deserialize data to/from formats like JSON, XML etc., normalize data using the HAL (Hypertext Application Language), deal with authentication etc.
In addition to the core, there are helpful contributed modules like JSON API, Relaxed, Services, REST UI and more, which offer additional decoupling opportunities and are at the center of the community’s attention.
When it comes to non-RESTful decoupling tools, the hottest trend is using the GraphQL contributed module. It leverages the power of new query language made by Facebook for working with APIs — GraphQL. Among its other advantages, it enables the client side shape its requests to the server in such a way as to receive exactly what it needs, nothing less and nothing more.
OK, it’s time to use the exceptional opportunities that headless or decoupled Drupal 8 can provide for your project. Let’s discuss it, and our Drupal developers will bring it all to life with a great level of skill these projects deserve.