Skip to content

fix: preserve ids across server hydration - #166

Merged
KyleJune merged 1 commit into
mainfrom
codex/hydration-id-tree
Sep 28, 2026
Merged

KyleJune merged 1 commit into
mainfrom
codex/hydration-id-tree

Conversation

@KyleJune

Copy link
Copy Markdown
Member

Server-rendered pages could hydrate with different React useId values because the server added a hydration-script sibling beside the route tree while the browser rendered one child. Form labels and menu references retained server IDs while React generated different client IDs.

Reserve the script slot in the shared document component so both render paths have the same structure. Existing script order, Suspense, and nonce handling remain unchanged.

Testing

The regression hydrates actual createServer HTML through Client.hydrate, compares the committed hook ID to the original server ID, checks DOM reuse and label association, and rejects hydration diagnostics. It failed with _R_6_ versus _R_m_ before the fix and passes afterwards. deno task check and the full suite pass: 61 tests, 852 steps. Four independent source reviews found no outstanding issues.

Closes

Nothing. Related to the starter readiness work in udibo/udibo#1505.

@KyleJune
KyleJune merged commit ba8c77b into main Sep 28, 2026
10 checks passed
@KyleJune
KyleJune deleted the codex/hydration-id-tree branch September 28, 2026 03:10
KyleJune pushed a commit that referenced this pull request Sep 28, 2026
## [0.17.3](0.17.2...0.17.3) (2026-09-28)

### Bug Fixes

* preserve ids across server hydration ([#166](#166)) ([ba8c77b](ba8c77b))
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.17.3 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant