PagieraDocs Back to website

docs / publishing

Preview and publish

Keep drafts private, preview safely and render published pages.

Understand the three states

Saving, previewing and publishing are deliberately separate. Save updates the draft. Preview renders that draft through a protected route. Publish replaces the public version. Publishing content does not deploy your Next.js application or configure a domain.

Render the published page

Load the approved document on the server and hand its elements to the runtime.

tsx
import { notFound } from "next/navigation";
import { RenderedPage } from "pagiera/runtime";
import { getPagieraServer, pagieraConfigFromEnv } from "pagiera/server";

export async function PublishedPage({ slug }: { slug: string }) {
  const server = await getPagieraServer(pagieraConfigFromEnv());
  const page = await server.getPublishedPage(slug, { page: { slug } });
  if (!page) notFound();
  return <RenderedPage elements={page.elements} />;
}

Add a protected preview route

The preview route should accept a page ID, verify the current user can edit it, load the draft and render it with the same runtime used in production. Add noindex metadata so preview URLs cannot enter search results.

Publish safely

  1. Save the current draft.
  2. Open the protected preview on desktop, tablet and mobile widths.
  3. Verify dynamic data with realistic route and query values.
  4. Publish from the studio.
  5. Request the public URL in a fresh session.
  6. Confirm that the initial HTML contains important text and data.

Rollback strategy

Treat the page document as production data. Keep database backups and, when your workflow requires approval history, record published revisions before replacement.