Skip to content

Support React SSR import maps - #8217

Open
mattcosta7 wants to merge 2 commits into
TanStack:mainfrom
mattcosta7:feat/react-ssr-import-map
Open

Support React SSR import maps#8217
mattcosta7 wants to merge 2 commits into
TanStack:mainfrom
mattcosta7:feat/react-ssr-import-map

Conversation

@mattcosta7

@mattcosta7 mattcosta7 commented Sep 2, 2026

Copy link
Copy Markdown

🎯 Changes

Pass the router ssr.importMap option through to React's readable and pipeable streaming server renderers.

The import map shape is declared by the React router through an extensible core SSR options interface. This keeps router core framework-agnostic and preserves React 18 type compatibility, where ReactImportMap is not exported by @types/react-dom.

Adds coverage for both React streaming paths.

Tests:

  • pnpm test:eslint
  • pnpm test:types
  • pnpm test:unit

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested code changes locally with the relevant test commands, or tests do not apply to this pull request.
  • I fully understand the code in this pull request, including any code generated with AI assistance.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • New Features

    • Added SSR import-map configuration support for React streaming renderers.
    • Import maps can now be forwarded through both readable and pipeable streaming SSR modes.
    • Added public TypeScript types for configuring SSR options, including import maps and nonces.
  • Bug Fixes

    • Ensured configured SSR import maps are preserved during server-side rendering across supported streaming modes.

@coderabbitai

coderabbitai Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Team

Run ID: 9110f847-d845-4ee3-9021-c560b877931c

📥 Commits

Reviewing files that changed from the base of the PR and between 3564922 and 0796aeb.

📒 Files selected for processing (1)
  • packages/react-router/src/ssr/renderRouterToStream.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/react-router/src/ssr/renderRouterToStream.tsx

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

The router core now exposes reusable SSR option types. React Router adds typed import-map support and forwards the configured import map to both React streaming SSR renderers. Tests cover readable and pipeable rendering.

Changes

SSR import-map forwarding

Layer / File(s) Summary
SSR option contract
packages/router-core/src/router.ts, packages/router-core/src/route.ts, packages/router-core/src/index.ts, packages/react-router/src/router.ts
The router core exports reusable SSR option types. React Router extends the options with importMap, including imports, integrity, and scopes.
Streaming renderer forwarding
packages/react-router/src/ssr/renderRouterToStream.tsx, packages/react-router/tests/renderRouterToStream.test.tsx, .changeset/curly-dodos-import.md
Both React streaming renderers receive router.options.ssr?.importMap. Tests verify readable and pipeable stream forwarding. A changeset declares patch releases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 0796a

This change passes the configured SSR import map through both React streaming render paths; no actionable merge-blocking risk remains after normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant RouterOptions
  participant renderRouterToStream
  participant ReactDOMServer
  RouterOptions->>renderRouterToStream: provide ssr.importMap
  renderRouterToStream->>ReactDOMServer: pass importMap to streaming renderer
  ReactDOMServer-->>renderRouterToStream: return readable or pipeable stream
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 6 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description follows the required template. It explains the change and motivation, lists test commands, completes all checklist items, and documents the changeset for published code.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding React SSR import-map support.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@mattcosta7
mattcosta7 marked this pull request as ready for review September 2, 2026 17:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant