nextPreviewHandlers
#
A function that provides API handlers to implement Next.js's preview mode.
#
ParametersnextPreviewHandlers
accepts a configuration object parameter, with the following options:
#
Usage#
Basic exampleCreate the file ./pages/api/preview/[[...handle]].ts
with the following contents:
To open preview mode of a story at /article/article-1
, go to:
/api/preview?token=YOUR_PREVIEW_TOKEN&slug=article/article-1
You can configure preview mode as a preview URL in Storyblok:
YOUR_WEBSITE/api/preview?token=YOUR_PREVIEW_TOKEN&slug=
If you are using the preview handlers and are on a page configured with withStory
, you will automatically be shown a small indicator to remind you that you are viewing the page in preview mode. It also allows you to exit preview mode. Alternatively you can go to /api/preview/clear
to exit preview mode.