Company
Date Published
Author
Paul Bratslavsky
Word count
2515
Language
English
Hacker News points
None

Summary

Strapi 5 introduces a powerful preview feature that allows content editors to view draft content directly on the frontend before publishing. This is perfect for editorial workflows where content needs review or approval before going live, helping catch layout or formatting issues early. To set up the preview feature in Strapi and Next.js, you need to configure the Strapi backend with a preview configuration and create a secure preview route in your Next.js app using `app/api/preview/route.ts`. The preview handler securely accesses the preview request parameters from the URL, enables or disables Next.js Draft Mode based on the status value, and redirects users to the correct preview path. Additionally, you need to update the article page to support previewing draft vs published content and pass the correct status parameter to the `getArticleBySlug` function. With just a few configuration changes, you can unlock a powerful preview experience for your content team using Strapi and Next.js.