Problem statement
In a decoupled frontend setup, Publive manages content but your app controls rendering. To preview content inside your frontend, you need a route that can fetch the requested content from Publive and render it using the same templates as the live site.What you are doing
You will create a dynamic Next.js page, fetch the requested content on the server withidentify, and render the correct page template based on the identified content type.
This pattern is based on pages/post/[id].tsx in your app.
Core flow
Create a route that matches the preview URL structure used by your app. UsegetServerSideProps so the page can fetch fresh preview data for every request.
The key server-side step is resolving the requested page from Publive with identify. For the SDK behavior, see JavaScript SDK.
draft_entity or draft. If identify returns no content, or the type is outside those values, return notFound.
Load supporting page data
Your reference page also fetches shared layout data such as:- publisher data
- navbar content
- footer content
- slots
getServerSideProps flow.
Render by content type
After fetching the content, render the matching page template. The important point is to reuse the same components your live routes use. If your app supports additional page types such as blank canvas pages or web stories, handle those here as well.Core pieces you need
- a dynamic route that matches your preview URL shape
getServerSidePropsfor request-time fetching- a Publive
identifycall for the requested path - shared layout data needed by your page
- a type check for
draft_entityordraft - template selection based on returned content type
Notes
- Keep preview fetching server-side.
- Return
notFoundwhen Publive does not identify any content or the identified type is notdraft_entityordraft. - Reuse your production rendering components so preview output stays accurate.