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
andfetchJsonApiEndpoint
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.