Package Exports
- @sanity/preview-url-secret
- @sanity/preview-url-secret/create-secret
- @sanity/preview-url-secret/define-preview-url
- @sanity/preview-url-secret/package.json
- @sanity/preview-url-secret/without-secret-search-params
Readme
@sanity/preview-url-secret
Warning
This is an experimental package. Breaking changes may be introduced at any time. It's not production ready.
npm i --save-exact @sanity/preview-url-secret@pink-lizard @sanity/client
Usage
TODO how to verify the secret in an API handler that enables Draft Mode
Presentation Tool
@TODO move to presentation tool docs
import { presentationTool } from '@sanity/presentation'
import { definePreviewUrl } from '@sanity/preview-url-secret/presentation'
import { visionTool } from '@sanity/vision'
import { defineConfig } from 'sanity'
import { deskTool } from 'sanity/desk'
export default defineConfig({
projectId,
dataset,
schema,
plugins: [
presentationTool({
// The URL you usually would pass into `previewUrl`:
// previewUrl: 'http://localhost:3000/en/home',
// You now pass into `definePreviewUrl`, slightly modified:
previewUrl: definePreviewUrl({
// You first specify the shared baseUrl:
origin: 'http://localhost:3000',
preview: '/en/home', // Optional, it's '/' by default
// The API route that securely puts the app in a "Draft Mode"
// Next.js docs: https://nextjs.org/docs/app/building-your-application/configuring/draft-mode
draftMode: {
enable: '/api/draft',
},
}),
}),
deskTool(),
visionTool(),
],
})