DrupalClient

A powerful client to fetching Drupal JSON:API data.


⚠️

The `DrupalClient` is available in `next-drupal ^1.3.0` as experimental.

The `DrupalClient` is an optional feature. You can safely upgrade your site to `next-drupal 1.3.0` without any breaking changes.

The `DrupalClient` is a powerful JSON:API client that ships with helpers for fetching Drupal data and building pages.

It is a replacement for functional helpers such as `getResource`, `getResourceCollection` ...etc.

Features

  1. Customizable JSON:API client for data fetching.
  2. Helpers to fetching resources, menus, views and search indices.
  3. Support for custom auth (`Bearer`, `Basic` or bring your own).
  4. Support for custom serializers.
  5. Support for custom fetcher.
  6. Support for cached resources (memory cache, redis...etc).
  7. Improved error messages.

Usage

import { Experimental_DrupalClient as DrupalClient } from "next-drupal"
const drupal = new DrupalClient("https://example.com")
// Fetch articles.
const articles = await drupal.getResourceCollection("node--article")
👉

See the guide here to upgrade your site to use the new `DrupalClient`.