Configure Draft Routes

Draft routes in Next.js


Implement draft mode using two API routes.

If you're using the Basic Starter, draft routes are already created for you.

/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)
}

/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()
}