Skip to content

feat(cms): add live preview for pages and posts#418

Merged
hakalb merged 4 commits intomainfrom
cod-377-support-live-preview
Apr 15, 2026
Merged

feat(cms): add live preview for pages and posts#418
hakalb merged 4 commits intomainfrom
cod-377-support-live-preview

Conversation

@hakalb
Copy link
Copy Markdown
Member

@hakalb hakalb commented Apr 15, 2026

Summary

  • Adds @payloadcms/live-preview-react dependency
  • Configures admin.livePreview in payload.config.ts with mobile/tablet/desktop breakpoints, scoped to pages and posts; URL function routes pages to /{slug} and posts to /posts/{slug}
  • Adds generic LivePreview.client.tsx component that wraps useLivePreview — centralises the hook call and reads serverURL from PayloadProvider context
  • Adds *-preview.client.tsx wrappers for landing page, pages, and posts; each is a thin render-function client boundary used by the RSC page components
  • Adds optional PREVIEW_URL env var (falls back to serverURL; set to the web client URL when running in host mode)

Notes

  • Real-time preview (as-you-type) uses the client-side useLivePreview approach rather than RefreshRouteOnSave; the server-side approach requires autosave/versions to show unsaved changes, which is planned for the next issue
  • RefreshRouteOnSave is included as a reference but unused — will be revisited when versions/drafts/autosave lands

Test plan

  • Open a page or post in the CMS admin
  • Click the Live Preview button
  • Edit content — preview updates in real-time without saving
  • Verify mobile/tablet/desktop breakpoint switcher works in the preview panel

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 15, 2026 18:31
@bolt-new-by-stackblitz
Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@nx-cloud
Copy link
Copy Markdown

nx-cloud bot commented Apr 15, 2026

View your CI Pipeline Execution ↗ for commit bc2dbf6

Command Status Duration Result
nx affected -t e2e --exclude *,!tag:scope:nx-pa... ✅ Succeeded 8m 2s View ↗
nx affected -t integration-test -c ci ✅ Succeeded 2m 35s View ↗
nx affected -t e2e -c ci --exclude nx-payload-e2e ✅ Succeeded 7m 29s View ↗
nx affected -t lint,test,build -c ci ✅ Succeeded 4m 44s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 8s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-15 21:53:57 UTC

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Payload CMS live preview support to the CMS Next.js app so editors can see real-time updates for pages and posts in the admin preview panel.

Changes:

  • Add @payloadcms/live-preview-react dependency.
  • Configure admin.livePreview in apps/cms/src/payload.config.ts (breakpoints + URL resolver for pages/posts).
  • Introduce client live preview components (LivePreview.client.tsx and per-route *-preview.client.tsx wrappers) and wire them into the RSC routes.

Reviewed changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pnpm-lock.yaml Locks the added live preview dependency and its transitive deps.
package.json Adds @payloadcms/live-preview-react dependency.
apps/cms/src/payload.config.ts Enables/admin-configures live preview (breakpoints, collections, URL mapping).
apps/cms/src/components/RefreshRouteOnSave.tsx Adds a client component wrapper for “refresh on save” live preview (currently unused).
apps/cms/src/components/LivePreview.client.tsx Adds a generic client wrapper around useLivePreview using PayloadProvider context.
apps/cms/src/app/(site)/posts/[...slug]/post-preview.client.tsx Client boundary to live-preview posts.
apps/cms/src/app/(site)/posts/[...slug]/page.tsx Switches post rendering to use the live preview client boundary.
apps/cms/src/app/(site)/page.tsx Switches landing page rendering to use the live preview client boundary.
apps/cms/src/app/(site)/landing-page-preview.client.tsx Client boundary to live-preview the landing page.
apps/cms/src/app/(site)/[...slug]/page.tsx Switches page rendering to use the live preview client boundary.
apps/cms/src/app/(site)/[...slug]/page-preview.client.tsx Client boundary to live-preview pages (threads through pre-fetched blocksData).
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/cms/src/components/LivePreview.client.tsx
Comment thread apps/cms/src/payload.config.ts
Comment thread apps/cms/src/payload.config.ts
Comment thread apps/cms/src/app/(site)/[...slug]/page-preview.client.tsx
@codeware-actions
Copy link
Copy Markdown

✨ Your pull request project is ready for preview

Project App name Preview
cms (demo) cdwr-cms-pr-418-demo https://cdwr-cms-pr-418-demo.fly.dev

@hakalb hakalb added the preview-deploy PR Trigger: run continuous preview deployments label Apr 15, 2026
Comment thread apps/cms/src/payload.config.ts
@codeware-actions
Copy link
Copy Markdown

✨ Your pull request projects are ready for preview

Project App name Preview
cms (_default) cdwr-cms-pr-418 https://cdwr-cms-pr-418.fly.dev
cms (demo) cdwr-cms-pr-418-demo https://cdwr-cms-pr-418-demo.fly.dev
web (demo) cdwr-web-pr-418-demo https://cdwr-web-pr-418-demo.fly.dev

@hakalb hakalb removed the preview-deploy PR Trigger: run continuous preview deployments label Apr 15, 2026
@hakalb hakalb enabled auto-merge April 15, 2026 21:28
@hakalb hakalb added this pull request to the merge queue Apr 15, 2026
@sentry
Copy link
Copy Markdown

sentry bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.19%. Comparing base (1e489aa) to head (bc2dbf6).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #418      +/-   ##
==========================================
+ Coverage   64.04%   64.19%   +0.15%     
==========================================
  Files         199      207       +8     
  Lines        5270     5348      +78     
  Branches      716      735      +19     
==========================================
+ Hits         3375     3433      +58     
- Misses       1856     1865       +9     
- Partials       39       50      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Merged via the queue into main with commit a0b1751 Apr 15, 2026
16 checks passed
@hakalb hakalb deleted the cod-377-support-live-preview branch April 15, 2026 21:57
@hakalb hakalb deployed to preview April 15, 2026 21:59 — with GitHub Actions Active
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants