2.0.0-preview-kit.1 (2022-11-11)
⚠ BREAKING CHANGES
- General purpose preview mode is now maintained in
@sanity/preview-kit
. Use it on routes that don't live inside the/app
folder introduced in Next 13.
The new mode for Next 13 provides two new APIs that supportsReact.use
andReact.cache
as implemented in Next 13 React Server Components:
import {PreviewSuspense, definePreview, groq} from 'next-sanity'
import {previewData} from 'next/headers'
const usePreview = definePreview({projectId, dataset})
export default async function ServerComponent() {
const token = previewData()?.token
if(token) return <PreviewSuspense fallback="Loading Preview Mode..."><PreviewList token={token} /></PreviewSuspense>
const client = createClient({projectId, dataset})
const data = await client.fetch(groq`*[]`)
return <List data={data} />
}
function PreviewList({token}) {
const data = usePreview(token, groq`*[]`)
return <List data={data} />
}
Features
- add new preview mode for Next 13 (a22ddb3)
Bug Fixes
This release is also available on: