未验证 提交 f1c4cb8b 编写于 作者: L Luis Alvarez D 提交者: GitHub

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

Fixes https://github.com/vercel/next.js/issues/16661
上级 ce994365
......@@ -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`.
### 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`
Both the bypass cookie value and the private key for encrypting the `previewData` change when `next build` is completed.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册