next-sanity
Version:
Sanity.io toolkit for Next.js
46 lines (41 loc) • 1.16 kB
TypeScript
import {SanityClient} from '@sanity/client'
/**
* Sets up an API route for enabling draft mode, can be paired with the `previewUrl.previewMode.enable` in `sanity/presentation`.
* Can also be used with `sanity-plugin-iframe-pane`.
* @example
* ```ts
* // src/app/api/draft-mode/enable/route.ts
*
* import { defineEnableDraftMode } from "next-sanity/draft-mode";
* import { client } from "@/sanity/lib/client";
*
* export const { GET } = defineEnableDraftMode({
* client: client.withConfig({ token: process.env.SANITY_API_READ_TOKEN }),
* });
* ```
*
* @public
*/
export declare function defineEnableDraftMode(
options: DefineEnableDraftModeOptions,
): EnableDraftMode
/**
* @public
*/
export declare interface DefineEnableDraftModeOptions {
client: SanityClient
/**
* Force secure cookies in development mode.
* Enable this when using Next.js --experimental-https flag.
* This option has no effect in production (cookies are always secure).
* @defaultValue false
*/
secureDevMode?: boolean
}
/**
* @public
*/
export declare interface EnableDraftMode {
GET: (request: Request) => Promise<Response>
}
export {}