You can set up a live preview of your website inside the dashboard.
Create the following route in the app folder to handle previews:
import {cms} from '@/cms'
export const GET = cms.previewHandler
Update your CMS config with the preview url:
export const cms = createNextCMS({
// schema and workspaces ...
preview:
process.env.NODE_ENV === 'development'
? 'http://localhost:3000/api/preview'
: '/api/preview'
})
Include the preview widget (<cms.previews />) in your root layout:
import {cms} from '@/cms'
export default async function Layout({children}: PropsWithChildren) {
return (
<>
<header />
<main>{children}</main>
<footer />
<cms.previews />
</>
)
}