Configure Preview Routes

Preview routes in Next.js

If you're using the Basic Starter, preview routes are already configure for you.

To implement preview mode:

  1. Set a `previewSecret` on the `DrupalClient`. This is the same secret used when creating your site on Drupal.
  2. Implement preview mode using two API routes.


import { NextApiRequest, NextApiResponse } from "next"
import { drupal } from "lib/drupal"
export default async function handler(
request: NextApiRequest,
response: NextApiResponse
) {
return await drupal.preview(request, response)


import { NextApiResponse } from "next"
export default function exit(_, response: NextApiResponse) {
response.writeHead(307, { Location: "/" })