Unverified Commit f1c4cb8b authored by Luis Alvarez D's avatar Luis Alvarez D Committed by GitHub

Update preview mode docs to include API Routes (#16705)

Fixes https://github.com/vercel/next.js/issues/16661
parent ce994365
...@@ -203,6 +203,18 @@ You can pass an object to `setPreviewData` and have it be available in `getStati ...@@ -203,6 +203,18 @@ You can pass an object to `setPreviewData` and have it be available in `getStati
The preview mode works on `getServerSideProps` as well. It will also be available on the `context` object containing `preview` and `previewData`. The preview mode works on `getServerSideProps` as well. It will also be available on the `context` object containing `preview` and `previewData`.
### Works with API Routes
API Routes will have access to `preview` and `previewData` under the request object. For example:
```js
export default function myApiRoute(req, res) {
const isPreview = req.preview
const previewData = req.previewData
// ...
}
```
### Unique per `next build` ### Unique per `next build`
Both the bypass cookie value and the private key for encrypting the `previewData` change when `next build` is completed. Both the bypass cookie value and the private key for encrypting the `previewData` change when `next build` is completed.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment