Skip to content

feat(exo): example apps opt into editor preview via enablePreview [SPA-4692]#29

Draft
Thomas Kellermeier (Chaoste) wants to merge 1 commit into
spike/spa-4692-component-previewfrom
spike/spa-4692-component-preview--example-integration
Draft

feat(exo): example apps opt into editor preview via enablePreview [SPA-4692]#29
Thomas Kellermeier (Chaoste) wants to merge 1 commit into
spike/spa-4692-component-previewfrom
spike/spa-4692-component-preview--example-integration

Conversation

@Chaoste

@Chaoste Thomas Kellermeier (Chaoste) commented Jul 10, 2026

Copy link
Copy Markdown

Stacked on #28. Demonstrates the minimum diff a customer applies to consume the new preview capabilities.

Summary

  • Both the Next.js and SvelteKit examples call ExperienceRenderer — the hybrid renderer — directly from their server component / server load, and pass enablePreview on. No client-boundary shell needed; picking the right renderer at the import site is the whole customer-side change.
  • Server render (via ServerExperienceRenderer internally) emits static first-paint HTML — SEO-friendly, no blank flash for slow devices.
  • After hydration, ExperienceRenderer hands off to ClientExperienceRenderer, which owns the preview wire. Outside the Contentful editor the wire is a no-op — the SDK's ancestorOrigins check refuses to connect.

The three-renderer split, at the call site

// Marketing / blog / landing — pure SSR, no interactivity:
import { ServerExperienceRenderer } from '@contentful/experiences-react';

// Editable / preview-capable route — SSR + hydration + preview wire:
import { ExperienceRenderer } from '@contentful/experiences-react';

// Advanced client-only (tests, native shells):
import { ClientExperienceRenderer } from '@contentful/experiences-react';

Changes

  • Next.js: app/[slug]/page.tsx + app/advanced/[slug]/page.tsx — swap ServerExperienceRenderer for ExperienceRenderer + enablePreview. That's the entire customer-side diff.
  • SvelteKit: src/routes/[slug]/+page.svelte — same swap.

Bundle-size impact (next build)

  • /[slug] route: 119 B (unchanged)
  • First Load JS: 107 kB (unchanged)
  • The renderer was already client-side via hydration; only the prop shape changed.

Both the Next.js and SvelteKit examples call `ExperienceRenderer` —
the hybrid renderer from `@contentful/experiences-react` /
`-svelte` — directly from their server component / server load and
pass `enablePreview` on. No client-boundary shell needed; picking the
right renderer at the import site is the whole customer-side change.

- Server render (via `ServerExperienceRenderer` internally) emits
  static first-paint HTML.
- After hydration, `ExperienceRenderer` hands off to
  `ClientExperienceRenderer`, which owns the preview wire. Outside
  the Contentful editor the wire is a no-op — ancestorOrigins check
  refuses to connect.

Bundle-size impact: `/[slug]` route stays at 119 B; First Load JS
107 kB — the renderer was already client-side via hydration.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant