Upgrade Guide

Guide for upgrading your site to use DrupalClient.


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.

  1. Upgrade to `next-drupal 1.3.0`:
yarn add next-drupal@latest
  1. Create a new `DrupalClient` in `lib/drupal.ts`


import { Experiment_DrupalClient as DrupalClient } from "next-drupal"
export const drupal = new DrupalClient(
frontPage: process.env.DRUPAL_FRONT_PAGE,
previewSecret: process.env.DRUPAL_PREVIEW_SECRET,
auth: {
clientId: process.env.DRUPAL_CLIENT_ID,
clientSecret: process.env.DRUPAL_CLIENT_SECRET,
  1. Update helpers to use the `drupal` client.
+ import { drupal } from "lib/drupal"
- await getPathsFromContext()
+ await drupal.getStaticPathsFromContext()
- await translatePathFromContext()
+ await drupal.translatePathFromContext()
- await getResourceFromContext()
+ await drupal.getResourceFromContext()
  1. Replace `pages/api/preview.ts` with the following:
- import { DrupalPreview } from "next-drupal"
- export default DrupalPreview()
+ import { drupal } from "lib/drupal"
+ export default async function (request, response) {
+ return await drupal.preview(request, response)
+ }
  1. On the Drupal site, visit `/admin/people/permissions/anonymous` and assign the Issue subrequests permission to the Anonymous user role:

    We do this because during the build phase, most of the requests for pages are anonymous requests. By assigning this permission, you can significantly decrease your site's build time.

    If you would rather keep requests authenticated, you can use the `withAuth` options.

  2. Done. You are now ready to run your site using the new `DrupalClient`.

Thanks for testing out our 1.3 release. If you see any bugs during the upgrade, feel free to create an issue on GitHub.