Skip to content
Source
Sign inSign up
TanStack/router

feat: Link header #7327

Mergedschiller-manuel(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/7327/headmerged by schiller-manuel(GitHub profile, opens in a new tab)

Summary by CodeRabbit

  • New Features

    • Added opt-in responseLinkHeader configuration to append collected Early Hints as Link headers in final responses
    • Added support for filtering response Link headers with custom filters
  • Documentation

    • Updated Early Hints guide with new response Link header configuration details and examples
  • Tests

    • Added test coverage for response Link header generation and filtering
    • Enhanced E2E tests to validate final response Link headers
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsdocumentation

    2. github-actions[bot](GitHub profile, opens in a new tab) added labelspackage: start-server-core

    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration

      Configuration used: defaults

      Review profile: CHILL

      Plan: Pro

      Run ID: 0e080315-3a51-435c-b82e-1fe0a45fce9f

      📥 Commits

      Reviewing files that changed from the base of the PR and between e0fb8ec4601644128907972e9d03abf54fa4a539 and 3134b4467b372a105ca3a404e48575f1d49a7594.

      📒 Files selected for processing (9)
      • .changeset/fresh-ligers-clean.md
      • docs/start/framework/react/guide/early-hints.md
      • e2e/react-start/early-hints/src/server.ts
      • e2e/react-start/early-hints/tests/early-hints-protocol.spec.ts
      • packages/start-server-core/src/createStartHandler.ts
      • packages/start-server-core/src/early-hints.ts
      • packages/start-server-core/src/index.tsx
      • packages/start-server-core/src/request-handler.ts
      • packages/start-server-core/tests/early-hints.test.ts

      📝 Walkthrough

      Walkthrough

      This PR introduces an opt-in responseLinkHeader configuration to append collected Early Hints as Link headers in the final HTML response. It refactors early hints handling to support both onEarlyHints callbacks and optional response header injection, adds supporting types and utilities, updates documentation with new examples, and provides E2E and unit test coverage.

      Changes

      Early Hints Response Link Header Feature

      Layer / File(s)Summary
      Types & Public API
      packages/start-server-core/src/early-hints.ts, packages/start-server-core/src/index.tsx
      New exported types: ResponseLinkHeaderEntry, ResponseLinkHeaderFilter, ResponseLinkHeaderOptions. New helpers: createResponseLinkHeaderEntries (deduplicates and serializes hints), getResponseLinkHeaderEntries (extracts and optionally filters links with error handling).
      Request Options Extension
      packages/start-server-core/src/request-handler.ts
      EarlyHintsOptions gains optional responseLinkHeader?: boolean | ResponseLinkHeaderOptions property to control whether collected Early Hints are appended to the response Link header.
      Core Implementation
      packages/start-server-core/src/createStartHandler.ts
      Refactored early hints handling: replaced sendEarlyHintsEvent with notifyEarlyHints, handleCollectedEarlyHints, and appendResponseLinkHeaders helpers. Early hints are now collected conditionally when onEarlyHints or responseLinkHeader is provided (outside dev mode). Static/dynamic hints flow through unified collector. Response Link headers are appended after base headers when enabled.
      Documentation & Examples
      docs/start/framework/react/guide/early-hints.md
      Renamed section to "Response Link Header and CDNs" with updated guidance on when Start adds response headers. Replaces manual onEarlyHints-based example with responseLinkHeader: true and responseLinkHeader.filter examples. Clarifies limitations: mutation only occurs when responseLinkHeader is enabled.
      E2E & Unit Tests
      e2e/react-start/early-hints/src/server.ts, e2e/react-start/early-hints/tests/early-hints-protocol.spec.ts, packages/start-server-core/tests/early-hints.test.ts
      E2E server now includes responseLinkHeader: true. New test validates final response Link header contains modulepreload and preconnect links; redirect test asserts empty Link header. Unit tests cover getResponseLinkHeaderEntries for combined headers, filtering by phase, and error handling.
      Release
      .changeset/fresh-ligers-clean.md
      Patch version bump for @tanstack/start-server-core, @tanstack/react-start-server, @tanstack/solid-start-server, and @tanstack/vue-start-server.

      Estimated code review effort

      🎯 3 (Moderate) | ⏱️ ~25 minutes

      Poem

      🐰 Hop along, the hints now flow, Link headers in a gentle glow, Response heads with care, we send, Early hints from start to end! ✨

      🚥 Pre-merge checks | ✅ 3 | ❌ 2

      ❌ Failed checks (1 warning, 1 inconclusive)

      Check nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring coverage is 10.00% which is insufficient. The required threshold is 80.00%.Write docstrings for the functions missing them to satisfy the coverage threshold.
      Title check❓ InconclusiveThe title 'feat: Link header' is overly generic and vague. While it relates to the changeset (which adds response Link header functionality), it lacks specificity about the primary feature being introduced—the responseLinkHeader configuration option for appending Early Hints to HTML responses.Consider a more descriptive title such as 'feat: Add responseLinkHeader option to append Early Hints to response Link headers' to better convey the main change.
      ✅ Passed checks (3 passed)
      Check nameStatusExplanation
      Description Check✅ PassedCheck skipped - CodeRabbit’s high-level summary is enabled.
      Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
      ✏️ Tip: You can configure your own custom pre-merge checks in the settings.
      ✨ Finishing Touches
      📝 Generate docstrings
      • Create stacked PR
      • Commit on current branch
      🧪 Generate unit tests (beta)
      • Create PR with unit tests
      • Commit unit tests in branch `link-header`

      Review rate limit: 4/5 reviews remaining, refill in 12 minutes. Comment `@coderabbitai help` to get the list of available commands and usage tips.
    4. nx-cloud[bot](GitHub profile, opens in a new tab)commented

      View your CI Pipeline Execution ↗ for commit 3134b4467b372a105ca3a404e48575f1d49a7594

      CommandStatusDurationResult
      nx affected --targets=test:eslint,test:unit,tes...❌ Failed4m 35sView ↗
      nx run-many --target=build --exclude=examples/*...✅ Succeeded2sView ↗

      ☁️ Nx Cloud last updated this comment at 2026-05-02 23:29:54 UTC

    5. github-actions[bot](GitHub profile, opens in a new tab)commented

      🚀 Changeset Version Preview

      4 package(s) bumped directly, 5 bumped as dependents.

      🟩 Patch bumps

      PackageVersionReason
      @tanstack/react-start-server1.166.49 → 1.166.50Changeset
      @tanstack/solid-start-server1.166.48 → 1.166.49Changeset
      @tanstack/start-server-core1.167.27 → 1.167.28Changeset
      @tanstack/vue-start-server1.166.44 → 1.166.45Changeset
      @tanstack/react-start1.167.60 → 1.167.61Dependent
      @tanstack/react-start-rsc0.0.39 → 0.0.40Dependent
      @tanstack/solid-start1.167.57 → 1.167.58Dependent
      @tanstack/start-plugin-core1.169.15 → 1.169.16Dependent
      @tanstack/vue-start1.167.53 → 1.167.54Dependent
    6. github-actions[bot](GitHub profile, opens in a new tab)commented

      Bundle Size Benchmarks

      • Commit: e0fb8ec46016
      • Measured at: 2026-05-02T23:26:26.892Z
      • Baseline source: history:238ea4a4998a
      • Dashboard: bundle-size history
      ScenarioCurrent (gzip)Delta vs baselineRawBrotliTrend
      react-router.minimal87.15 KiB0 B (0.00%)273.94 KiB75.70 KiB█▁▁▁▁▁▁▁▁▁▁
      react-router.full90.68 KiB0 B (0.00%)285.45 KiB78.71 KiB█▁▁▁▁▁▁▁▁▁▁
      solid-router.minimal35.38 KiB0 B (0.00%)106.25 KiB31.81 KiB█▁▁▁▁▁▁▁▁▁▁
      solid-router.full40.10 KiB0 B (0.00%)120.46 KiB36.04 KiB█▁▁▁▁▁▁▁▁▁▁
      vue-router.minimal53.15 KiB0 B (0.00%)151.39 KiB47.73 KiB█▁▁▁▁▁▁▁▁▁▁
      vue-router.full58.28 KiB0 B (0.00%)167.56 KiB52.18 KiB█▁▁▁▁▁▁▁▁▁▁
      react-start.minimal101.76 KiB0 B (0.00%)322.10 KiB87.97 KiB█▁▁▁▁▁▁▁▁▁▁
      react-start.full105.19 KiB0 B (0.00%)332.43 KiB90.96 KiB█▁▁▁▁▁▁▁▁▁▁
      react-start.rsbuild.minimal99.33 KiB0 B (0.00%)316.47 KiB85.46 KiB█▁▁▁▁▁▁▁▁▁▁
      react-start.rsbuild.full102.63 KiB0 B (0.00%)326.90 KiB88.28 KiB█▁▁▁▁▁▁▁▁▁▁
      solid-start.minimal49.40 KiB0 B (0.00%)152.08 KiB43.60 KiB█▁▁▁▁▁▁▁▁▁▁
      solid-start.full55.20 KiB0 B (0.00%)168.98 KiB48.51 KiB█▁▁▁▁▁▁▁▁▁▁

      Trend sparkline is historical gzip bytes ending with this PR measurement; lower is better.

    7. More templates

      @tanstack/arktype-adapter

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

      @tanstack/eslint-plugin-router

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

      @tanstack/eslint-plugin-start

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

      @tanstack/history

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

      @tanstack/nitro-v2-vite-plugin

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

      @tanstack/react-router

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

      @tanstack/react-router-devtools

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

      @tanstack/react-router-ssr-query

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

      @tanstack/react-start

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

      @tanstack/react-start-client

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

      @tanstack/react-start-rsc

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

      @tanstack/react-start-server

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

      @tanstack/router-cli

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

      @tanstack/router-core

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

      @tanstack/router-devtools

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

      @tanstack/router-devtools-core

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

      @tanstack/router-generator

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

      @tanstack/router-plugin

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

      @tanstack/router-ssr-query-core

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

      @tanstack/router-utils

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

      @tanstack/router-vite-plugin

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

      @tanstack/solid-router

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

      @tanstack/solid-router-devtools

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

      @tanstack/solid-router-ssr-query

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

      @tanstack/solid-start

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

      @tanstack/solid-start-client

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

      @tanstack/solid-start-server

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

      @tanstack/start-client-core

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

      @tanstack/start-fn-stubs

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

      @tanstack/start-plugin-core

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

      @tanstack/start-server-core

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

      @tanstack/start-static-server-functions

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

      @tanstack/start-storage-context

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

      @tanstack/valibot-adapter

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

      @tanstack/virtual-file-routes

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

      @tanstack/vue-router

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

      @tanstack/vue-router-devtools

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

      @tanstack/vue-router-ssr-query

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

      @tanstack/vue-start

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

      @tanstack/vue-start-client

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

      @tanstack/vue-start-server

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

      @tanstack/zod-adapter

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

      commit: 3134b44

    8. Nx Cloud has identified a flaky task in your failed CI:

      🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

      Nx Cloud View detailed reasoning in Nx Cloud ↗


      🎓 Learn more about Self-Healing CI on [nx.dev](https://nx.dev/docs/features/ci-features/self-healing-ci?utm_source=pull-request&utm_medium=comment)
    9. codspeed[bot](GitHub profile, opens in a new tab)commented

      Merging this PR will not alter performance

      ✅ 5 untouched benchmarks ⏩ 1 skipped benchmark1


      Comparing link-header (86ba81a) with main (238ea4a)[^unexpected-base] Open in CodSpeed

      Footnotes

      1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports. ↩

    10. Nx Cloud has identified a flaky task in your failed CI:

      🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

      Nx Cloud View detailed reasoning in Nx Cloud ↗


      🎓 Learn more about Self-Healing CI on [nx.dev](https://nx.dev/docs/features/ci-features/self-healing-ci?utm_source=pull-request&utm_medium=comment)

Sign in to join this conversation.