Serializer

Using a custom serializer with DrupalClient.


⚠️

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

The `DrupalClient` uses jsona as the default serializer for serializing and deserializing JSON:API data.

You can provide your own using the `serializer` option.

Example

Here's how you can replace the default serializer with jsonapi-serializer.

lib/drupal.ts

import { Experiment_DrupalClient as DrupalClient } from "next-drupal"
import { Deserializer } from "jsonapi-serializer"
const customSerializer = new Deserializer({
keyForAttribute: "camelCase",
})
export const drupal = new DrupalClient(
process.env.NEXT_PUBLIC_DRUPAL_BASE_URL,
{
serializer: customSerializer,
}
)