Skip to content

feat(website): native ?renderJson support in the Fresh handler - #1612

Closed
marcoferreiradev wants to merge 2 commits into
deco-cx:mainfrom
marcoferreiradev:pr/render-json
Closed

feat(website): native ?renderJson support in the Fresh handler#1612
marcoferreiradev wants to merge 2 commits into
deco-cx:mainfrom
marcoferreiradev:pr/render-json

Conversation

@marcoferreiradev

@marcoferreiradev marcoferreiradev commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

What is this Contribution About?

Native ?renderJson support in the website Fresh handler — the consumer side of the section-controlled JSON rendering introduced in deco-cx/deco#1208.

  • website/handlers/fresh.ts: a native ?renderJson branch (sibling of ?asJson, with renderJson taking precedence, guarded by !isJsonOneShot). Serves the JSON projection produced by each section's renderJson export via the runtime's serializeResolvedSection / computeRenderCb.
  • website/mod.ts: a renderJson.sectionsToIgnore admin prop so a site can override which sections are dropped from the JSON payload, instead of a hardcoded denylist.
  • Drops the legacy ?appJson alias — ?renderJson is its replacement. The standalone ?asJson mode is left untouched.

Issue Link

Companion to the runtime feature — depends on it:

Status / dependency

Important

Draft — blocked on deco-cx/deco#1208. This PR imports computeRenderCb, serializeResolvedSection, ResolvedSection, sectionModuleLookup and SerializeContext from @deco/deco. Until #1208 is merged and published to JSR, deno task check fails with 5× TS2305: has no exported member ... for those symbols. deno fmt --check and deno lint are clean.

Test plan

  • deno fmt --check clean
  • deno check — blocked on chore: clearsale api #1208 (5× TS2305 for the not-yet-published runtime exports)
  • Dogfooded on a real deco storefront (oficina-reserva, pinned to the fork build): ?asJson and HTML byte-identical to baseline, ?renderJson matches the runtime serialization, lazy fetch applies the per-section projection.

Loom Video / Demonstration

Validated on the oficina-reserva storefront preview (pinned to the fork build). Loom/demo available on request.

🤖 Generated with Claude Code


Summary by cubic

Add native ?renderJson to the website Fresh handler to return structured page JSON that honors each section’s renderJson export. Replaces the old ?appJson alias and adds a setting to ignore app-owned sections.

  • New Features

    • Add ?renderJson endpoint that serializes sections via @deco/deco (computeRenderCb, serializeResolvedSection); takes precedence over ?asJson and disables async render for JSON responses.
    • Support section opt-out: respects per-section export const renderJson = false and a new renderJson.sectionsToIgnore app setting; skipped sections are not resolved or loaded.
    • Remove legacy ?appJson alias.
  • Dependencies

Written for commit a84e9f5. Summary will update on new commits.

Review in cubic

marcoferreiradev and others added 2 commits June 18, 2026 11:37
fresh.ts gains a structured-JSON exit alongside the existing ?asJson one:
?renderJson (legacy alias ?appJson — remove once consumers switch) resolves
the page with hooks that short-circuit sections opted out of JSON rendering
(their loaders never run), serializes the tree via @deco/deco
serializeResolvedSection honoring each section's `renderJson` export, and
responds { name, path, sections } with lazy sections as
{ component, lazyUrl } placeholders. One-shot JSON responses never use
async render (firstByteThreshold guards extended); renderJson takes
precedence when both params are sent; legacy ?asJson is untouched.

The website app gains `renderJson.sectionsToIgnore` (admin-configurable):
app-owned sections excluded by resolveType suffix — site-owned sections
should prefer `export const renderJson = false` in their own file.

Replaces the site-level wrapper pattern (handler + pages-loader fork) that
oficina-reserva ran as v1 — the default website/loaders/pages.ts now works
unchanged for renderJson consumers.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
renderJson is the replacement, not a sibling — consumers adopt ?renderJson
directly (validation happens on PR previews, nothing in production speaks
?appJson). Only the legacy ?asJson remains as a separate, untouched mode.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7596dfcb-ad95-47f7-8326-b190158d641c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 0.158.1 update
  • 🎉 for Minor 0.159.0 update
  • 🚀 for Major 1.0.0 update

@marcoferreiradev

Copy link
Copy Markdown
Contributor Author

Superseded by #1613 — reopening from the oficina-dev org fork (org contribution, not my personal fork).

@marcoferreiradev
marcoferreiradev deleted the pr/render-json branch June 18, 2026 14:45
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