Skip to content

studio: update CSR/SSR and 404 guides with latest drafts - #30

Merged
timbenniks-contentstack merged 1 commit into
contentstack:nextfrom
sumitjain-cstk:studio/sync-sdk-2.0
Nov 2, 2026
Merged

timbenniks-contentstack merged 1 commit into
contentstack:nextfrom
sumitjain-cstk:studio/sync-sdk-2.0

Conversation

@sumitjain-cstk

Copy link
Copy Markdown
Contributor

Follow-up to #29, which was merged before this commit was pushed. It updates the two new Studio guides with the latest drafts.

Changes

csr-and-ssr-requirements

  • Builder mode needs stackDetails.apiKey and .environment. environment falls back to stackSdk, apiKey doesn't.
  • ssr defaults (false with stackSdk, true without), and the stack's live_preview.ssr takes precedence.
  • A second init keeps the first instance, so restart the dev server after changing settings.
  • A frame-and-listen check confirms Visual Editor's handshake (visual-builder channel, init message) without signing in.
  • The client-side route sends only isCompositionNotFound errors to the 404 page and shows an error state for everything else.
  • On studio-react 2.0.1, refetchData only works for connected compositions, so the example falls back to refetchSpec.
  • SSR examples clear the shared stack's preview hash before each fetch.

handle-404-pages

  • isCompositionNotFound decides every 404. A bad token or an outage stays an error.
  • App Router uses cache() so the page and generateMetadata share one fetch.
  • Every server example clears the shared stack's preview hash before fetching. Without this, the next visitor can get the last editor's drafts.
  • A note on unpublished templates in the canvas.

CHANGELOG.md 0.3.1 lines are updated to match. No version bump: 0.3.1 hasn't been released yet.

Verification

  • node scripts/validate.mjs passes.
  • Every code block typechecks against @contentstack/studio-react 2.0.1 and @contentstack/live-preview-utils 4.5.3.
  • Live Preview claims were checked against the 4.5.3 source.

🤖 Generated with Claude Code

Bring in the updated drafts: isCompositionNotFound in every 404 branch,
cache() for one fetch per request, the canvas note on unpublished
templates, builder-mode stackDetails requirements, init .catch, the
?builder=true handshake check, and the first-instance rule for a second
init (all verified against live-preview-utils 4.5.3).

Keep the SDK fixes from review: clear the shared stack's preview hash
before each SSR fetch, refetchSpec fallback for freeform compositions on
studio-react 2.0.1, typed snippets (tsc strict passes), and
isCompositionNotFound on the CSR route.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sumitjain-cstk
sumitjain-cstk requested a review from a team as a code owner November 2, 2026 10:40
@snyk-io

snyk-io Bot commented Nov 2, 2026

Copy link
Copy Markdown

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Code Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@timbenniks-contentstack
timbenniks-contentstack merged commit 7786002 into contentstack:next Nov 2, 2026
5 of 7 checks passed
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.

2 participants