Skip to content

feat(solid-router): adopt Solid 2's useHead registry for head management - #8080

Merged
birkskyum merged 6 commits into
solid-router-v2-prefrom
solid-usehead-head-management
Aug 19, 2026
Merged

birkskyum merged 6 commits into
solid-router-v2-prefrom
solid-usehead-head-management

Conversation

@brenelz

@brenelz brenelz commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

Problem

HeadContent predates Solid 2's head management: it rendered head tags as
in-tree elements and carried a pile of workarounds to make that model work —
manual relocation of rendered nodes into document.head (for HeadContent
rendered in <body>), imperative document.title syncing, idempotent
imperative script injection for client-side navigation, hydration-id
landmines documented inline in Asset.tsx, reference-reuse machinery
(replaceEqualTags) so a <For> kept DOM nodes, and a dedicated
index.dev entry whose only job was a dev-styles variant of HeadContent.

Solid 2 (@solidjs/web 2.0.0-rc.0) ships a renderer-owned head registry
(useHead, per the head-management RFC): replaceable tags (title/meta/…)
resolve by last-committed group and stream as patches with their suspense
boundary's reveal; resource tags (stylesheets, preloads, script[src]) emit
eagerly and dedupe by identity; the client patches document.head
reactively and adopts server-flushed elements during hydration.

Mechanism

HeadContent is now a pure registration:

export function HeadContent(props: HeadContentProps) {
  const tags = useTags(props.assetCrossOrigin)
  useHead(() => toHeadTags(tags()))
  return <HydrationScript />
}
  • useTags keeps computing what the head contains (TanStack's
    route-head model: cross-match merge, child-wins meta dedupe, manifest
    CSS/preloads, nonce plumbing) — semantics unchanged. The registry now owns
    how tags reach the DOM on both runtimes.
  • toHeadTags is a pure data mapping (RouterManagedTag → HeadTag),
    evaluated inside the registry's flush boundary/effect, so it allocates no
    reactive owners (hydration-id safe). Inline-CSS placeholder recovery
    (client receives children === undefined and reads the server-rendered
    element's text) moves into this mapping.
  • Deleted: head-tag relocation and script-injection paths in the head
    pipeline, replaceEqualTags + the reference-reuse memo, and
    HeadContent.dev.tsx / index.dev.tsx / the development export
    conditions (the dev entry existed solely for the dev-styles variant).
  • HeadContent can now be rendered anywhere in the tree; keeping it in
    <head> remains the documented placement (the hydration script belongs
    early), so no doc changes.
  • Also carries the two request-level start-manifest e2e tests from fix(solid-start): harden SSR asset manifest wiring for SSR'd lazy() components #8050
    (head modulepreload hints + hydration _assets map for SSR'd lazy()
    components), which pin the seam this change rides on.

Behavior notes

  • Dev-styles link (DEV_STYLES_ATTR): the post-hydration removal is gone —
    the link now persists for the dev session. First paint stays styled (the
    blocking link is still SSR'd), edits still apply (Vite's injected style
    wins the cascade); the one papercut is that a deleted CSS rule keeps
    applying until a full reload. Verified against a live dev server.
  • Replaceable head tags apply on a registry microtask on the client instead
    of synchronously in-tree (one unit test updated accordingly).
  • Registry-emitted tags carry data-dh identity attributes in SSR output.

Verification

All on solid-router-v2-pre (solid-js 2.0.0-rc.0, @solidjs/vite-plugin
3.0.0-next.28):

  • @tanstack/solid-router unit (client + server modes): pass — except 4
    pre-existing failures unrelated to this change (remountDeps ×3 fails on
    the branch from the Solid 2 onMount removal; issue-7986 ×1), which
    fail identically without these commits.
  • Type tests across ts56–ts70: pass. eslint: 0 errors. publint + attw with
    the pruned exports: pass.
  • e2e start-manifest: 12 passed (10 pre-existing + the 2 ported tests).
  • e2e basic / csp / selective-ssr: running, results to follow in a
    comment.
  • Manual dev-mode run (vite dev, solid-start basic app): styled first
    paint (no FOUC), clean hydration, no console errors, registry-patched
    title/meta on client navigation, dev-styles endpoint serving.

Served dev SSR <head> (direct request to /posts — registry-rendered
tags carry data-dh identities, route title wins):

<link rel="stylesheet" href="/@tanstack-start/styles.css?routes=…" data-tanstack-router-dev-styles>
<link rel="modulepreload" href="/@id/virtual:tanstack-start-dev-client-entry">
<meta name="description" content="…" data-dh="meta:name:description">
<title data-dh="title">Posts page</title>

Supersedes the remaining delta of #8050 (its vite-plugin-solid pin bumps
are obsolete — the branch is already on @solidjs/vite-plugin next.28; its
test commit is included here).

🤖 Generated with Claude Code

brenelz and others added 3 commits August 15, 2026 18:46
HeadContent now feeds the route-derived tags (useTags output, semantics
unchanged) to Solid's head registry as one reactive group instead of
rendering <Asset> elements in-tree. The registry owns head emission on
both runtimes: SSR splices/streams resolved winners into <head>, the
client patches document.head reactively — replacing the manual
relocate-into-head, imperative script injection, and document.title
syncing that Asset.tsx carried for head tags.

The dev-only dev-styles handling (filter DEV_STYLES_ATTR links post
hydration) is a no-op in production, so it folds into the single
HeadContent — retiring HeadContent.dev.tsx, index.dev.tsx, and the
package's development export conditions.

Co-Authored-By: Claude Fable 5 <[email protected]>
… asset map

The client-assets manifest wiring (99756c0) gives SSR'd lazy()
components three observable outputs in the served HTML: modulepreload
hints for the lazy chunk and its static imports in the initial <head>,
the chunk's stylesheet link, and the serialized boundary→chunk asset map
that gates client hydration on those imports. The start-manifest e2e
only asserted the stylesheet side, so a silent regression to the
route-keyed manifest fallback would keep the suite green while losing
hints and hydration gating.

Two request-level tests against the built app pin the rest: direct SSR
entry to /lazy-css-lazy emits exactly one head modulepreload for the
lazy chunk and one for its statically imported widget chunk (and none of
them on routes that never render the component), and the hydration
payload's _assets map points at the same chunk URL the head hinted.

Co-authored-by: Cursor <[email protected]>
Drop the pieces of the head pipeline that existed only for the old
in-tree render path: the reference-reuse memo and replaceEqualTags (DOM
node stability for a <For> that no longer exists) and the dev-styles
post-hydration filtering (HeadContent is now a pure useHead
registration). Add the changeset for the useHead adoption.

Co-Authored-By: Claude Fable 5 <[email protected]>
@coderabbitai

coderabbitai Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d1abd7a4-ff06-4c7b-b1fe-cb7dae365431

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit 5278494

Command Status Duration Result
nx affected --targets=test:eslint,test:unit,tes... ✅ Succeeded 9m 2s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 40s View ↗

☁️ Nx Cloud last updated this comment at 2026-08-16 01:14:18 UTC

@github-actions

github-actions Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Changeset Version Preview

6 package(s) bumped directly, 0 bumped as dependents.

🟩 Patch bumps

Package Version Reason
@tanstack/solid-router 2.0.0-rc.0 → 2.0.0-rc.1 Changeset
@tanstack/solid-router-devtools 2.0.0-rc.0 → 2.0.0-rc.1 Changeset
@tanstack/solid-router-ssr-query 2.0.0-rc.0 → 2.0.0-rc.1 Changeset
@tanstack/solid-start 2.0.0-rc.0 → 2.0.0-rc.1 Changeset
@tanstack/solid-start-client 2.0.0-rc.0 → 2.0.0-rc.1 Changeset
@tanstack/solid-start-server 2.0.0-rc.0 → 2.0.0-rc.1 Changeset

@github-actions

github-actions Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Bundle Size Benchmarks

  • Commit: d574dc9ae5d8
  • Measured at: 2026-08-16T01:05:49.348Z
  • Baseline source: history:f97188fdb4c3
  • Dashboard: bundle-size history

The following scenarios have bundle-size changes compared with the baseline:

Scenario Current (gzip) Delta vs baseline Initial gzip Raw Brotli Trend
react-router.minimal 83.84 KiB +14 B (+0.02%) 83.70 KiB 262.48 KiB 72.97 KiB ▂▂▂▃██▆▂▂▁▁▂
react-router.full 87.35 KiB +30 B (+0.03%) 87.22 KiB 274.19 KiB 75.97 KiB ▄▄▄▄██▅▂▂▁▁▄
solid-router.minimal 39.31 KiB +6.19 KiB (+18.70%) 39.18 KiB 112.54 KiB 35.55 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-router.full 46.96 KiB +9.02 KiB (+23.77%) 46.83 KiB 136.17 KiB 42.22 KiB ▁▁▁▁▁▁▁▁▁▁▁█
vue-router.minimal 49.58 KiB +82 B (+0.16%) 49.46 KiB 138.42 KiB 44.75 KiB ▁█▇███▅▃▃▃▃█
vue-router.full 55.19 KiB +76 B (+0.13%) 55.07 KiB 156.63 KiB 49.65 KiB ▁█████▆▄▄▄▄█
react-start.minimal 96.66 KiB +40 B (+0.04%) 96.52 KiB 304.69 KiB 83.79 KiB ▄▄▄▄██▅▂▂▁▁▄
react-start.deferred-hydration 97.38 KiB +33 B (+0.03%) 96.54 KiB 306.05 KiB 84.51 KiB ▃▃▃▃██▅▃▃▁▁▃
react-start.full 99.83 KiB +32 B (+0.03%) 99.70 KiB 314.41 KiB 86.53 KiB ▄▄▄▄██▄▁▁▁▁▄
react-start.rsbuild.minimal 99.97 KiB +2 B (+0.00%) 99.79 KiB 315.11 KiB 86.19 KiB ▁▁▁▂███▃▃▁▁▁
react-start.rsbuild.full 103.29 KiB -1 B (-0.00%) 103.12 KiB 325.20 KiB 88.98 KiB ▁▁▁▂███▂▂▁▁▁
solid-start.minimal 60.61 KiB +14.74 KiB (+32.14%) 60.48 KiB 177.45 KiB 54.33 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-start.deferred-hydration 64.33 KiB +15.38 KiB (+31.41%) 61.05 KiB 185.56 KiB 57.76 KiB ▁▁▁▁▁▁▁▁▁▁▁█
solid-start.full 64.40 KiB +13.44 KiB (+26.37%) 64.28 KiB 188.80 KiB 57.63 KiB ▁▁▁▁▁▁▁▁▁▁▁█
vue-start.minimal 65.63 KiB +73 B (+0.11%) 65.51 KiB 189.24 KiB 58.42 KiB ▁█████▆▅▅▅▅█
vue-start.full 69.44 KiB +64 B (+0.09%) 69.31 KiB 201.55 KiB 61.64 KiB ▁█████▆▅▅▅▅█

Current gzip tracks all emitted client JS chunks. Initial gzip tracks only the entry/import graph. Trend sparkline is historical current gzip ending with this PR measurement; lower is better.

@pkg-pr-new

pkg-pr-new Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
More templates

@tanstack/arktype-adapter

npm i https://pkg.pr.new/@tanstack/arktype-adapter@8080

@tanstack/eslint-plugin-router

npm i https://pkg.pr.new/@tanstack/eslint-plugin-router@8080

@tanstack/eslint-plugin-start

npm i https://pkg.pr.new/@tanstack/eslint-plugin-start@8080

@tanstack/history

npm i https://pkg.pr.new/@tanstack/history@8080

@tanstack/nitro-v2-vite-plugin

npm i https://pkg.pr.new/@tanstack/nitro-v2-vite-plugin@8080

@tanstack/react-router

npm i https://pkg.pr.new/@tanstack/react-router@8080

@tanstack/react-router-devtools

npm i https://pkg.pr.new/@tanstack/react-router-devtools@8080

@tanstack/react-router-ssr-query

npm i https://pkg.pr.new/@tanstack/react-router-ssr-query@8080

@tanstack/react-start

npm i https://pkg.pr.new/@tanstack/react-start@8080

@tanstack/react-start-client

npm i https://pkg.pr.new/@tanstack/react-start-client@8080

@tanstack/react-start-rsc

npm i https://pkg.pr.new/@tanstack/react-start-rsc@8080

@tanstack/react-start-server

npm i https://pkg.pr.new/@tanstack/react-start-server@8080

@tanstack/router-cli

npm i https://pkg.pr.new/@tanstack/router-cli@8080

@tanstack/router-core

npm i https://pkg.pr.new/@tanstack/router-core@8080

@tanstack/router-devtools

npm i https://pkg.pr.new/@tanstack/router-devtools@8080

@tanstack/router-devtools-core

npm i https://pkg.pr.new/@tanstack/router-devtools-core@8080

@tanstack/router-generator

npm i https://pkg.pr.new/@tanstack/router-generator@8080

@tanstack/router-plugin

npm i https://pkg.pr.new/@tanstack/router-plugin@8080

@tanstack/router-ssr-query-core

npm i https://pkg.pr.new/@tanstack/router-ssr-query-core@8080

@tanstack/router-utils

npm i https://pkg.pr.new/@tanstack/router-utils@8080

@tanstack/router-vite-plugin

npm i https://pkg.pr.new/@tanstack/router-vite-plugin@8080

@tanstack/solid-router

npm i https://pkg.pr.new/@tanstack/solid-router@8080

@tanstack/solid-router-devtools

npm i https://pkg.pr.new/@tanstack/solid-router-devtools@8080

@tanstack/solid-router-ssr-query

npm i https://pkg.pr.new/@tanstack/solid-router-ssr-query@8080

@tanstack/solid-start

npm i https://pkg.pr.new/@tanstack/solid-start@8080

@tanstack/solid-start-client

npm i https://pkg.pr.new/@tanstack/solid-start-client@8080

@tanstack/solid-start-server

npm i https://pkg.pr.new/@tanstack/solid-start-server@8080

@tanstack/start-client-core

npm i https://pkg.pr.new/@tanstack/start-client-core@8080

@tanstack/start-fn-stubs

npm i https://pkg.pr.new/@tanstack/start-fn-stubs@8080

@tanstack/start-plugin-core

npm i https://pkg.pr.new/@tanstack/start-plugin-core@8080

@tanstack/start-server-core

npm i https://pkg.pr.new/@tanstack/start-server-core@8080

@tanstack/start-static-server-functions

npm i https://pkg.pr.new/@tanstack/start-static-server-functions@8080

@tanstack/start-storage-context

npm i https://pkg.pr.new/@tanstack/start-storage-context@8080

@tanstack/valibot-adapter

npm i https://pkg.pr.new/@tanstack/valibot-adapter@8080

@tanstack/virtual-file-routes

npm i https://pkg.pr.new/@tanstack/virtual-file-routes@8080

@tanstack/vue-router

npm i https://pkg.pr.new/@tanstack/vue-router@8080

@tanstack/vue-router-devtools

npm i https://pkg.pr.new/@tanstack/vue-router-devtools@8080

@tanstack/vue-router-ssr-query

npm i https://pkg.pr.new/@tanstack/vue-router-ssr-query@8080

@tanstack/vue-start

npm i https://pkg.pr.new/@tanstack/vue-start@8080

@tanstack/vue-start-client

npm i https://pkg.pr.new/@tanstack/vue-start-client@8080

@tanstack/vue-start-server

npm i https://pkg.pr.new/@tanstack/vue-start-server@8080

@tanstack/zod-adapter

npm i https://pkg.pr.new/@tanstack/zod-adapter@8080

commit: 5278494

@codspeed

codspeed Bot commented Aug 16, 2026 •

Copy link
Copy Markdown

Hooray! CodSpeed harness just leveled up!

The base and head of this comparison were measured with different runner settings, so their benchmark values are not directly comparable.

What changed between base and head:

Re-run the base with the same settings to get a valid performance comparison.


Comparing solid-usehead-head-management (5278494) with solid-router-v2-pre (67a9040)1

Open in CodSpeed

Footnotes

  1. No successful run was found on solid-router-v2-pre (1bdceb6) during the generation of this report, so 67a9040 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

…CI repairs

Inline scripts and styles get a stable content-derived key in toHeadTags:
the registry otherwise assigns per-runtime unique identities that can
never match between server and client, so hydration appended a client
copy next to the server-rendered tag (caught by the solid-start basic
script-duplication e2e).

The ssr head benchmark's sanity assertion now counts name="…" attribute
occurrences instead of raw substring hits — the registry writes the
identity into data-dh on the same element, which doubled the old count.

remountDeps tests migrate onMount to Solid 2's onSettled (pre-existing
branch failure; the API was removed in the rc line).

Co-Authored-By: Claude Fable 5 <[email protected]>

@nx-cloud nx-cloud Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important

At least one additional CI pipeline execution has run since the conclusion below was written and it may no longer be applicable.

Nx Cloud has identified a possible root cause for your failed CI:

We investigated both CI failures and determined neither is caused by the changes in this PR. The issue-7986-retained-pending unit test failure is explicitly acknowledged by the author as pre-existing, and the e2e CSS assertion failure (~6.6% historical flakiness rate) is also confirmed present in branch 8081 — both failures exist independently of this head-registry refactor.

No code changes were suggested for this issue.

Trigger a rerun:

Rerun CI

Nx Cloud View detailed reasoning on Nx Cloud ↗


🎓 Learn more about Self-Healing CI on nx.dev

…background recovery)

Two compounding defects kept a captured route error from retrying
cleanly on Solid 2:

- CatchBoundary's reset effect re-ran on every recompute of the reset
  key, not only on value changes, so any store write recreated the
  retried subtree while it settled. The effect is now gated on the key
  value. The reset handle deliberately stays un-consumed: a reset
  applied at the wrong moment can no-op (the boundary stays errored and
  the fallback never re-runs), and only a repeated attempt on a later
  key change recovers it — consuming the handle at apply time or at
  children re-render both proved to lose exactly that retry (verified
  against the background-recovery test).

- Match keyed its boundary on the whole matches store, so every
  unrelated transition fired a premature reset that re-threw the
  still-stale error and flapped the error UI. The key is now scoped to
  the guarded match and its descendants (whose errors bubble here when
  they have no errorComponent), mirroring react-router's per-match
  keying, as a value string because the store emits fresh objects for
  content-equal writes.

The issue-7986 pending assertion queries fresh under waitFor: the
retried subtree renders the pending fallback from two nested slots in
quick succession (Show fallback, then the Loading boundary once the
child suspends), so a cached element handle can go stale across the
swap.

First fully green unit run on this branch: 59 files, 864 tests.

Co-Authored-By: Claude Fable 5 <[email protected]>
@birkskyum
birkskyum merged commit b60b741 into solid-router-v2-pre Aug 19, 2026
25 checks passed
@birkskyum
birkskyum deleted the solid-usehead-head-management branch August 19, 2026 15:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants