Skip to content
Vincle
Esc

Loading…

    Adapters

    An adapter controls how placeholders and patches are encoded in the HTML shell. It is a required argument of renderToStream and renderToStatic: there is no implicit default.

    import { renderToStream } from "@vincle/flow";
    import { NativeAdapter } from "@vincle/flow/adapters";
    
    const stream = renderToStream(() => <Page />, NativeAdapter);
    

    Built-in adapters#

    All exported from @vincle/flow/adapters.

    Adapter Target Merge support Size
    NativeAdapter Inline polyfill via <template data-for> replace, append, prepend, before, after ~1.5 kB polyfill (gzipped)
    TurboAdapter Turbo Streams (<turbo-frame> / <turbo-stream>) the six above + morph (Turbo >= 8) N/A
    HtmxAdapter HTMX (hx-swap-oob) the six above + morph (htmx >= 4) N/A
    WebPlatformAdapter Declarative partial updates (WICG proposal) replace only N/A
    EsiAdapter CDN edge composition via esi:include replace N/A

    Merge types#

    merge Effect
    "replace" Target element is replaced (default)
    "update" Target's content is replaced, element kept
    "append" Content inserted as last child of target
    "prepend" Content inserted as first child of target
    "before" Content inserted as previous sibling
    "after" Content inserted as next sibling
    "morph" Target is diffed against content in place

    "morph" keeps focus, scroll position and form state. A merge the adapter does not support is rejected at registration.