Skip to content

Support Vue's built-in components (<Transition>, <TransitionGroup>, <KeepAlive>, <Teleport>, <Suspense>) #167

Open

Description

@JuroOravec

(Opus 5.5)

Problem

Vue's built-in components <Transition>, <TransitionGroup>, <KeepAlive>, <Teleport> and <Suspense> can't be used in Citry templates. Citry rejects them when the template loads.

Why they're unsupported today

The browser bundle already contains all five (Citry ships the full Vue runtime). They're blocked because:

  • Citry's compiler output check only allows a fixed list of runtime helpers, and these compile to helpers outside it.
  • The server renderer, which writes the HTML Vue later takes over, can't render them.
  • Several of them change where or when DOM exists, which Citry's server-driven updates rely on.

Feasibility, per component (estimates, not yet prototyped)

  • Transition / TransitionGroup — most feasible. They only animate in the browser, and the server can render the child (or the TransitionGroup wrapper tag). Risk: a server update removing nodes in the middle of an animation. Medium effort.
  • Teleport — content leaves the component's root element, which affects how Citry finds a component's elements, attaches listeners and places updates, and needs server HTML and hydration support for the target. Hard.
  • KeepAlive — cached instances are deactivated rather than unmounted, which conflicts with server-driven remounts. Hard, low value. Not planned unless requested.
  • Suspense — needs async component setup, which Citry's model doesn't have. Very hard. Not planned unless requested.

Start with Transition and TransitionGroup.

Activity

  1. changed the title [-]Support Vue's built-in components (Transition first)[/-] [+]Support Vue's built-in components (<Transition>, <TransitionGroup>, <KeepAlive>, <Teleport>, <Suspense>)[/+] on Oct 2, 2026
  2. JuroOravec commented on Oct 25, 2026

    @JuroOravec
    MemberAuthor

    Parked for now (low priority). This is the design note worked out so far, kept here so the work can resume from it.

    What blocks all five today

    • Compiler output check. _vue/compiler.py accepts only a fixed list of Vue runtime helpers (about
      lines 400-435). The five built-ins compile to helpers outside it (Transition, TransitionGroup,
      KeepAlive, Teleport, Suspense), so the template fails when it loads. This is the error users see.
    • Server renderer. crates/citry_vue_compiler/src/server_render.rs recognises none of the five. If
      the helper check let them through, the renderer would mark them unsupported, and the page would
      fall back to rendering in the browser.
    • The helper contract (HELPER_CONTRACT_DESCRIPTOR, "ordinary-vnodes/1") treats block helpers as
      plain vnodes. Adding a helper changes the contract hash. That is fine, and it is how a new helper
      should be introduced, so stale cached definitions are refused.

    Decision summary

    Component Plan Phase
    <Transition> Support 1
    <TransitionGroup> Support 1
    <Teleport> Support later, for full-page renders only 2
    <KeepAlive> Keep rejected, with a clearer error Not planned
    <Suspense> Keep rejected, with a clearer error Not planned

    1. <Transition> (phase 1)

    • Server HTML: only the child. Vue's own server renderer writes no wrapper element for a
      Transition, and its props (name, mode, appear, the class names) produce no markup.
    • Hydration: Vue hydrates the child as usual. With appear, the browser runs the enter animation
      on the first mount; the server HTML already shows the final state, so nothing jumps.
    • Citry server renderer: treat Transition as transparent. Render its default slot and drop its
      props. This is close to how the renderer already handles a component's default slot.
    • Server-driven updates: an Events render that replaces the subtree while an animation runs
      unmounts the transitioning element. Vue cancels the pending callbacks on unmount, so this is safe.
      The leave animation of the replaced node simply does not finish. The docs should say so.
    • Pages without Vue: <Transition> cannot render there, so it fails the same way as other Vue
      syntax on a page without Vue.
    • Error modes:
      • More than one root child inside <Transition>: Vue only warns about this. Citry should fail when
        the template loads, naming the rule, "one element or component, or one v-if chain".
      • mode with a value other than out-in or in-out: fail at load.
      • Inside a Citry component tag (<c-Panel>), <Transition> works only as content of a fill, like
        any other Vue element.

    2. <TransitionGroup> (phase 1)

    • Server HTML: the element named by tag with the children inside, or the children alone when
      there is no tag. Transition props produce no markup. The tag element's other attributes pass
      through.
    • Hydration: Vue hydrates the wrapper and the children. A reorder caused by Vue state animates
      with Vue's move transition.
    • Citry server renderer: render the tag element, or a fragment, and then the children. Drop
      moveClass and the transition props.
    • Server-driven updates: an Events render of the list replaces it, so there is no move
      animation between server renders. Document that animated reordering comes from browser state, not
      from server renders.
    • Error modes:
      • A direct child without a key: Vue requires one. Citry should fail at load, with the same
        message style as the existing #c-key check for repeated components.
      • A c-for (server-repeated) child: this works, because each item gets a key. The docs should show
        :key on the Vue side and #c-key on the Citry side.

    3. <Teleport> (phase 2)

    • Server HTML: Vue writes <!--teleport start--><!--teleport end--> anchors where the
      <Teleport> stands, and collects the content separately. The page must place that content into the
      target element, such as body or #modals.
    • Hydration: Vue looks for the content inside the target, between its own anchors. If the server
      did not place it there, hydration reports a mismatch and the content renders in the browser instead.
    • Why it is hard for Citry:
      • Citry finds a component's elements, attaches its listeners, and places Events updates through
        its root elements. Teleported content is outside them.
      • An Events render returns a fragment for one component. It cannot add content to a target
        elsewhere in the page.
    • Proposed rule:
      • Support <Teleport> only where Citry renders the whole document, so the server can place the
        content into the target in the same response.
      • In a fragment or an Events render, a <Teleport> whose target lies outside the fragment fails
        with a clear error.
      • disabled teleports render in place and are always allowed.
      • defer teleports render in the browser only, and the docs warn about the flash.
    • Error modes:
      • The target is not found in the rendered document: fail when the page serialises, naming the
        selector.
      • A teleport inside a fragment whose target lies outside it: fail, as above.
      • An event binding (@c-*) inside teleported content: phase 2 must prove that Citry still routes
        it to the owning component. If that cannot be guaranteed, reject it in teleported content.

    4. <KeepAlive> (not planned)

    • Server HTML: only the active child.
    • Conflict: KeepAlive deactivates cached instances instead of unmounting them. Citry's
      server-driven updates replace instances and their State tokens, so a reactivated cached instance
      would hold stale State and a stale token.
    • Decision: keep it rejected. Replace the generic helper error with "KeepAlive is not supported
      in Citry; use v-show to keep a component's state while it is hidden".

    5. <Suspense> (not planned)

    • Server HTML: Vue resolves async setups before writing the default branch.
    • Conflict: Citry components have no async setup. Their data comes from the server render.
    • Decision: keep it rejected, with a specific error saying that Citry components render with
      their data already resolved, so Suspense has nothing to wait for.

    What changes in the spec and docs

    • vue/limits.md: move Transition and TransitionGroup from "unsupported" to a supported section with
      the rules above. Keep KeepAlive and Suspense listed with the reasons. Mark Teleport "planned, full
      pages only".
    • The helper allowlist and the contract descriptor gain Transition and TransitionGroup, which
      produces a new contract hash.
    • Parity corpus: pages for Transition with a v-if child, Transition with appear, and TransitionGroup
      with and without tag. This keeps the server HTML equal to the first browser render.

    What would show this design is wrong

    • Vue's compiled output for <Transition> uses a helper that needs the block-tracking optimisations
      Citry turns off (openBlock=noop in the contract), and the transition misbehaves under
      "ordinary-vnodes" rendering. This is the first thing to check, with one compiled sample.
    • Server-driven updates of transitioning content turn out to be common, for example a toast list
      rendered by the server, so the missing leave animation makes the feature feel broken. A
      browser-side list driven by js_data would then be the recommended pattern, and the docs must say
      so up front.

    Risk (a) checked: compiled output for Transition and TransitionGroup

    I compiled one sample of each with Citry's own Vue compiler (citry_core._rust.vue._compile_vue, the
    ordinary target) and read the output:

    • <Transition name="fade"><p v-if="show">x</p></Transition> compiles to
      _createBlock(_Transition, { name: "fade" }, { default: _withCtx(() => [ v-if branch ]), _: 1 }).
    • <TransitionGroup tag="ul" name="list"><li v-for ... :key="i"> compiles to
      _createBlock(_TransitionGroup, { tag, name }, { default: _withCtx(() => [ _renderList(...) ]) }),
      with a keyed fragment inside.
    • Every helper used is already on Citry's allowlist: openBlock, createBlock, createElementBlock,
      createCommentVNode, withCtx, renderList and Fragment. The only new names are the two
      component objects, Transition and TransitionGroup. The compiler's own audit reports exactly
      that: UNSUPPORTED_HELPER: unsupported Vue helper Transition (and TransitionGroup).
    • Nothing uses _cache, setBlockTracking or withMemo, which _FORBIDDEN_CODE rejects, and the
      output carries only the usual patch-flag hints that the contract already ignores
      (createBlock=createVNode-ignore-hints).

    Answer: the output needs no block-tracking feature that the ordinary-vnodes contract turns off.
    Vue's transition hooks attach to individual vnodes and its keyed children, not to the block tree, so
    full-diff patching is compatible. The change is: allow the two component objects, declare them in the
    contract descriptor (for example Transition=pass;TransitionGroup=pass), and teach the server renderer
    to render them transparently. Not yet verified: a real enter and leave run in a browser under
    Citry's runtime. That belongs in the phase-1 e2e test.

  3. added
    next-sprint
    on Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    next-sprint

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions