Draft Mode

Using draft mode with NextDrupal client.


To implement draft mode, configure entity types on Drupal. See the guide here.

  1. Implement /app/api/draft/route.ts.

app/api/draft/route.ts

import { drupal } from "@/lib/drupal"
import { enableDraftMode } from "next-drupal/draft"
import type { NextRequest } from "next/server"
export async function GET(request: NextRequest): Promise<Response | never> {
return enableDraftMode(request, drupal)
}
  1. Implement /app/api/disable-draft/route.ts

app/api/disable-draft/route.ts

import { disableDraftMode } from "next-drupal/draft"
import type { NextRequest } from "next/server"
export async function GET(request: NextRequest) {
return disableDraftMode()
}