Hydration and adoption
How your app's JavaScript takes over views that are already on screen without rebuilding them.
Hydration is the moment your app's JavaScript takes over the snapshot screen. Adoption is how it does that: instead of mounting its first render as new views, Octapus matches it against the snapshot and hands the existing views to your app. The term comes from Octane's native renderer design, where a runtime's first commit is "accepted in adoption mode": it describes the screen that is already there rather than instructing the host to build it again.
The sequence
launch
├─ draw the snapshot (no JS) phase: frame
├─ Hermes renders the first commit (in parallel)
└─ the hydration strategy fires phase: hydrating
├─ match → views handed to your app phase: adopted (0 views created)
│ held taps delivered
└─ mismatch → snapshot dropped, normal render phase: remounted
no snapshot → normal render phase: mountedHow the match works
Octapus flattens both trees in the same order (parents before children, text nodes included) and compares them row by row:
- Both trees must have the same number of rows.
- Each row must have the same element type (
div,button, text …) and the same parent. - Text inside a block of text must be identical.
Props, styles and event handlers are not compared. Once the views belong to your app, its normal update path applies them, exactly as it would after any render. That keeps the match cheap and robust: a different class name or handler does not throw the snapshot away.
When the trees match, each snapshot view is bound to the matching element of your app. No view is created, which is why viewsCreatedOnAdopt is expected to be 0.
When the trees differ
The snapshot is dropped and your app's first commit is mounted from scratch. Nothing is lost except time, and the launch metrics record the first difference so you can fix the cause (Troubleshooting).
Early input
Because the snapshot is real native views, it can be tapped before JavaScript is ready. Octapus holds those events while the phase is frame or hydrating. After adoption it maps each one from the snapshot view to your app's element and delivers it if that element has a handler for the event, in the original order. Held events are dropped rather than delivered when the match failed or the snapshot came from a different bundle.
Relation to Octane
Octane hydrates server-rendered HTML with <Hydrate when={…}> per boundary: the HTML is shown until the boundary's condition fires, then the boundary becomes interactive. Octapus applies the same idea to a native screen: the snapshot plays the server HTML, and HydrationStrategy plays when for the whole screen, with the same strategy names (load, idle, interaction, never).