Skip to content

feat(vue): write a v-slot fill's server HTML with the props its slot passes - #447

Merged
JuroOravec merged 1 commit into
mainfrom
feat/vue-slot-props-ssr
Oct 27, 2026
Merged

JuroOravec merged 1 commit into
mainfrom
feat/vue-slot-props-ssr

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

What this does

Stacked on #445, which adds <c-slot :row> and <c-fill v-slot>. Review that one first; this PR's diff is the commit on top.

When the server writes a page's HTML for Vue to adopt, it now writes a v-slot fill too, with the values its <c-slot> passes:

{# Inside List; js_data() returns rows such as {"id": 1, "title": "Apple"} #}
<li v-for="row in rows" :key="row.id">
  <c-slot name="item" :row="row" />
</li>

{# The caller #}
<c-fill name="item" v-slot="{ row }">
  <b v-text="row.title"></b>
</c-fill>

The page now shows <b>Apple</b> before Vue starts, and Vue adopts it. Before this change, the server left the fill's place empty, and Vue built the element around the component tag in the browser.

How

The behavior change is in crates/citry_vue_compiler/src/server_render.rs. The docs, the design plan, and the citry and citry_core changelogs are updated to match.

  • Slot functions it reads. It reads a fill's slot function when it takes no parameter, one name, or one object pattern with no nested pattern and no default. That covers what Citry writes, such as { $citryI18nBinding, $i18n, row } and { key: citrySlotKey, ...p }, and renames such as { row: item }.
  • Where the props come from. The props come from the renderSlot call of the receiving component's <slot>, evaluated with that component's own data, and are bound as the fill's locals. A props object that a middle component passes on with v-bind is read through Vue's props helpers. Props built with _mergeProps make every prop unknown.
  • Unknown props. A prop the server cannot read, such as a data() value or $i18n, binds as unknown. Only the parts of the fill that read it are left for the browser to build.
  • Refused patterns. A nested pattern or a default is refused (slot-props), and Vue builds the element around the <c-slot> in the browser. The pattern's names still bind, as unknown, so that element's server HTML never reads an outer fill's value of the same name.

What does not change

  • A page with a configured i18n extension is still left to Vue as a whole (custom-hooks). So an i18n page still shows no server HTML for these fills; the { $i18n, row } form is covered by a Rust test only.
  • hydration.rs ignores slot parameters, so the hydration anchors are unchanged.

Tests

  • Rust: each slot function form, props read with the outlet's data rather than the caller's, a rest that leaves out the listed props, unknown props, a prop the outlet does not pass (undefined, as in Vue), a nested pattern declined, a middle component passing the props object on, and nested fills that use the same name inside an element the browser builds.
  • Python: pages serialized with each form, which also feed the render parity check. scripts/vue_render_parity/check.py over these pages: 0 mismatches against Vue's renderToString.
  • e2e: a page whose fills the server writes, including an attribute bound to a slot prop. It hydrates with every element reused and no mismatch.

Part of #168.

🤖 Generated with Claude Code

@JuroOravec
JuroOravec added this pull request to stack #454 October 27, 2026 16:35
Base automatically changed from feat/vue-slot-props to main October 27, 2026 16:40
…passes

The server renderer now reads a fill's slot function when it takes one
name or one flat object pattern, such as { $i18n, row, row: item,
key: citrySlotKey, ...rest }. It evaluates the props the outlet's
renderSlot passes with the outlet component's data and binds them as the
fill's locals, so a page whose rows come from js_data shows its v-slot
fills before Vue starts, and Vue adopts that HTML. A props object passed
on with v-bind is read through Vue's props helpers. A prop the server
cannot read binds as unknown, so only the parts that read it become
shells. A nested pattern or a default declines as slot-props; its names
still bind, as unknown, so shell contents never read an outer fill's value
of the same name.

Part of #168.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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