Skip to content

Commit f1c4cb8

Browse files
authoredAug 31, 2020
Update preview mode docs to include API Routes (#16705)
Fixes #16661
1 parent ce99436 commit f1c4cb8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎docs/advanced-features/preview-mode.md

+12
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,18 @@ You can pass an object to `setPreviewData` and have it be available in `getStati
203203

204204
The preview mode works on `getServerSideProps` as well. It will also be available on the `context` object containing `preview` and `previewData`.
205205

206+
### Works with API Routes
207+
208+
API Routes will have access to `preview` and `previewData` under the request object. For example:
209+
210+
```js
211+
export default function myApiRoute(req, res) {
212+
const isPreview = req.preview
213+
const previewData = req.previewData
214+
// ...
215+
}
216+
```
217+
206218
### Unique per `next build`
207219

208220
Both the bypass cookie value and the private key for encrypting the `previewData` change when `next build` is completed.

0 commit comments

Comments
 (0)
Please sign in to comment.