@prismicio/next
Version:
Helpers to integrate Prismic into Next.js apps
44 lines (43 loc) • 1.82 kB
TypeScript
import type { LinkResolverFunction, Client } from "@prismicio/client";
import type { NextApiRequestLike, NextApiResponseLike } from "./types";
export type RedirectToPreviewURLConfig = {
/** The Prismic client configured for the preview session's repository. */
client: Pick<Client, "resolvePreviewURL">;
/**
* The `req` object from a Next.js API route.
*
* @see Next.js API route docs: \<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\>
*/
req: NextApiRequestLike;
/**
* The `res` object from a Next.js API route.
*
* @see Next.js API route docs: \<https://nextjs.org/docs/pages/building-your-application/routing/api-routes\>
*/
res: NextApiResponseLike;
/**
* A Link Resolver used to resolve the previewed document's URL.
*
* @see To learn more about Link Resolver: {@link https://prismic.io/docs/core-concepts/link-resolver-route-resolver}
*/
linkResolver?: LinkResolverFunction;
/**
* The default redirect URL if a URL cannot be determined for the previewed
* document.
*
* **Note**: If you `next.config.js` file contains a `basePath`, the
* `defaultURL` option must _not_ include it. Instead, provide the `basePath`
* property using the `basePath` option.
*/
defaultURL?: string;
/**
* The `basePath` for the Next.js app as it is defined in `next.config.js`.
* This option can be omitted if the app does not have a `basePath`.
*
* @remarks
* The Router Handler or API route is unable to detect the app's `basePath`
* automatically. It must be provided to `redirectToPreviewURL()` manually.
*/
basePath?: string;
};
export declare function redirectToPreviewURL(config: RedirectToPreviewURLConfig): Promise<void>;