Drupal State

A lightweight data store and utilities intended to simplify managing data sourced from Drupal.

Drupal Core offers a fantastic set of zero-config API endpoints that can make content from Drupal easily available to any JavaScript frontend. But consuming this data can require custom code along with an understanding of both the JSON:API specification and some amount of Drupal specific knowledge.

Drupal State aims to bridge this gap by offering a common set of utilities that allow JavaScript developers with limited knowledge of Drupal or the JSON:API spec to take advantage of the best features of Drupal’s APIs. These utilities can also be used by related projects in the Drupal ecosystem so that the community can spend less time re-solving common problems and more time pushing Decoupled Drupal forward.

Features include:

  • βœ… Retrieve an object from Drupal’s API, then serve all future requests for that object from local state.

  • βœ… Framework agnostic - use with vanilla JS or any of your favorite JavaScript frameworks.

  • βœ… API data is represented in a simplified, deserialized structure.

  • βœ… Easily add filters and include additional resources using Drupal JSON:API Params.

  • βœ… Universal - can be used on both client side and server side.

  • βœ… Access the store directly when necessary.

  • βœ… Import individual utility functions like fetchApiIndex and fetchJsonApiEndpoint if you only need some of the features of Drupal State.

  • βœ… Easily source data from API endpoints that require authorization

Plus much more on the roadmap. Have a feature request? Submit it in the issue queue.