shiftzero

Patches & variants

A variant is a list of changes — from a one-word copy swap to a full section redesign. Every change maps to a typed patch the edge applies in a single streaming pass.

The vocabulary

KindWhat it doesApplied
domRewrite an element's text contentedge (streaming)
attrSet or remove an attribute (class, href, src…)edge (streaming)
insertAdd new HTML before/after/inside an element — banners, badges, sectionsedge (streaming)
replaceSwap an element for new HTML entirelyedge (streaming)
removeDelete matching elementsedge (streaming)
cssInject a stylesheet into <head> — restyles apply before first paintedge (streaming)
jsInject behaviour at end of <body> — nudges, toggles, handlersbrowser
json-islandPatch embedded JSON state (__NEXT_DATA__, any application/json script) so hydrated components mount into the variantedge (streaming)
flightValue-scoped substitution inside an RSC Flight stream (Next.js App Router) — cross-chunk safe, length-prefix awareedge (streaming)
clientText change for DOM that only exists post-render (modals, JS widgets) — assignment still decided at the edgebrowser

The React problem, solved at the data layer

Changing server HTML under a hydrated component causes a hydration mismatch — React warns, re-renders, and users see a flicker. ShiftZero avoids the fight entirely: for framework pages it patches the data the component renders from, in the same edge pass as the HTML. A calculator widget with props in a JSON island mounts directly into the variant:

variant_b patches
[
  { "kind": "json-island", "selector": "script#calc-config",
    "path": ["headline"], "value": "Borrow £3,000 from £142/mo" },
  { "kind": "json-island", "selector": "script#calc-config",
    "path": ["cta"], "value": "Get my rate" }
]

Authoring

The wizard’s Variants step is a visual change-list — add changes from a typed menu, pick elements from your framed live page, write CSS/JS/HTML in real editors. The Code toggle round-trips the same list as raw patch JSON for power users. Serve-time patch-health diagnostics report selectors that stop matching (or match too much) on real traffic, with one-click self-healing proposals.

Rule of thumb the product enforces gently: content belongs at the edge (dom, css, insert, replace, json-island) — it’s flicker-free by construction. Behaviour belongs in the browser (js, client). Assignment and measurement stay at the edge either way.