Drupal Client
A powerful JSON:API client for Drupal.
The DrupalClient
is a powerful JSON:API client that ships with helpers for working with Drupal data.
You can use the DrupalClient
to fetch JSON:API data from Drupal to build static pages.
It also comes with full support for JSON:API write operations which means you can create JSON:API resources from Next.js to Drupal.
Features
- Customizable JSON:API client for data fetching.
- Helpers for fetching resources, menus, views and search indices.
- Helpers for JSON:API write operations (POST, PATCH, and DELETE)
- Support for custom auth (
Bearer
,Basic
,Next-Auth
or bring your own). - Support for custom serializers.
- Support for custom fetcher.
- Support for cached resources (memory cache, redis...etc).
- Human-readable error messages.
Usage
import { DrupalClient } from "next-drupal"
// Create a new DrupalClient.const drupal = new DrupalClient("https://example.com")
// Fetch articles.const articles = await drupal.getResourceCollection("node--article")
// Fetch one article by id.const article = await drupal.getResource( "node--article", "f4c61473-8297-4bf3-bab7-21c9633a7ca7")