Skip to content

perf(core): render Text and Heading in React Server Components - #11105

Open
imdreamrunner wants to merge 4 commits into
mainfrom
xinzi/rsc-text-heading
Open

imdreamrunner wants to merge 4 commits into
mainfrom
xinzi/rsc-text-heading

Conversation

@imdreamrunner

@imdreamrunner imdreamrunner commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Primary intent

Performance: a Server Component that renders Text or Heading renders them on the server, and the browser hydrates nothing for them. This ports the Text and Heading part of #8443 onto current main, co-authored with Royi Hagigi (every commit carries his Co-authored-by trailer). No other template fits: nothing is broken, nothing looks different, and no prop, type, default or export changes; unlike pure maintenance, it changes where these components render and when their code loads.

The rule, as in #8443: the presentational path renders on the server, and truncation lives in a client part that loads only when its props ask for it.

User or maintainer impact

Today Text.tsx, Heading.tsx and Text/index.ts start with 'use client'. A Server Component that renders <Text> or <Heading> can only emit a client reference, so the browser loads the whole client implementation (overflow measurement, the tooltip's first-interaction tracking, the clamp context) and hydrates every instance, even a plain line of text.

After this change, in a Server Component:

Props Client component rendered
no maxLines none
maxLines with hasTruncateTooltip={false}: Heading, or a Text that does not clamp (maxLines={0}, or capsize with more than one line) none
maxLines of 1 or more with hasTruncateTooltip={false} on Text TextClampScope only (below)
an explicit maxLines, 0 included, with the truncation tooltip on TruncatableText: measures, and mounts the Tooltip on the first hover, tap or focus. The Tooltip module stays a lazy chunk.

In client components nothing changes: the same markup, the same hooks, the same tooltip behavior.

Import path. import {Text} from '@astryxdesign/core/Text' (and @astryxdesign/core/Heading) gets the server render at once. import {Text} from '@astryxdesign/core' gets it only once the package root entry stops being a 'use client' module (the AST-113 FR4 gap in #11050). #11106 drops that directive from the root and the barrels; this PR does not touch the root entry. Both PRs remove the same two lines from Text/index.ts, so they merge cleanly in either order.

Bundle check (FR10)

A Next.js 16.3.6 production build of the repository's Next fixture (packages/build/__fixtures__/next-app.mjs, Core linked from source through withAstryx()), with three Server Component pages that import Text and Heading from their subpaths. The table is the client JavaScript a page loads beyond a page that renders no Astryx component, gzip, and the Text/Heading client components its RSC payload renders. "Before" is the same build with Core's source at main (7882c6028).

Page Turbopack (default), before Turbopack, after webpack (--webpack), before webpack, after
/plain: 2 Headings, 2 Texts, Text maxLines={0} and Heading maxLines={2} with the tooltip off 11.1 KB, 6 client components hydrate 8.9 KB, none hydrate 14.6 KB, 6 hydrate 0 KB, none
/clamped: Text maxLines={2} hasTruncateTooltip={false} 11.1 KB, 1 8.9 KB, 1 (TextClampScope) 13.4 KB, 1 11.1 KB, 1
/truncated: Text maxLines={2}, Heading maxLines={1} 11.1 KB, 2 8.9 KB, 2 (TruncatableText) 14.6 KB, 2 11.1 KB, 2
  • webpack loads only the client modules a page renders, so a page of Text and Heading without the truncation tooltip loads none of their code: FR10 holds.
  • Turbopack loads every client module that a page's server code imports, rendered or not. Text.tsx must import its client parts to render them for maxLines, so a Turbopack page that imports Text loads them even when it renders none. The browser still hydrates nothing for them. FR10's "zero in each supported bundler" cannot hold under Turbopack for any component whose server module renders a client part conditionally (it would apply to the Button and TopNav gates too). I did not change the wording of FR10; that is the spec owner's call.
  • Both bundlers put TextClampScope and TruncatableText in one route chunk, so the clamp-only page loads the same chunk as the tooltip page today. A bundler with one chunk per client module loads 0.5 KB gzip for the clamp scope alone (esbuild over source).

The one case routed to client code (FR6, FR12)

A Text with maxLines of 1 or more tells a nested Link that it is in clamped text, so the link renders inline (Link's clamped-text styles; main added this after #8443's base). Only a client component can provide a context. So a clamped Text with the tooltip off renders TextClampScope, a client part that only provides that context and adds no DOM. Without it, a nested Link would render different HTML on the server than in the client build (FR6) and behave differently before hydration (FR12); the parity and hydration cases with a nested Link fail without it (mutation-checked). Heading provides no clamp context, so a Heading with the tooltip off renders nothing on the client.

No remount in client renders

In #8443, Text and Heading rendered the plain element when maxLines was undefined (or the tooltip was off) and the client part otherwise, in client renders too. A caller that toggled maxLines to or from undefined, or toggled hasTruncateTooltip, changed the element type and remounted the element and its children.

Here the choice also depends on where the component renders:

  • Under React's react-server build (the build React Server Components render with), Text and Heading pick the plain element or a client part as the table above shows. isReactServer reads whether react has useState: the react-server build omits it. The check calls nothing.
  • In every other render (client components, server rendering of client components, tests) Text and Heading always render TruncatableText, the same tree as today. No prop change swaps the element type, so nothing remounts. Text/TruncatableText.test.tsx toggles maxLines between undefined, 0 and numbers, and hasTruncateTooltip between on, off and a placement, and checks that the element and a child keep their DOM nodes. It fails on perf(core): render Text, Heading, Kbd, Button, IconButton and TopNav in React Server Components #8443's rule (mutation-checked).

Known limitations (need an owner decision)

  • Server re-render remount. When a Server Component renders again (a navigation or a refresh) and the props move between rows of the table above (maxLines between unset and a number, or the tooltip on and off with maxLines set), React mounts a new element there: the first render has no client part, which is the saving. Changes between numbers with the tooltip on keep the element. A Server Component that toggles truncation can pass maxLines={0} instead of undefined. This rule is in no record or doc yet.
  • Passing Text itself as a prop. A Server Component that passes the subpath's Text or Heading component (not an element) to a client component, as in <Renderer component={Text} />, now fails next build with "Functions cannot be passed directly to Client Components". On main the subpath's Text is a client reference, so it builds. Any server module has this property; the fix for such a caller is to import Text in the client component. The changeset says so.
  • Authority. No current record owns the module boundary (architecture:component-style-authoring leaves it to a future RSC owner; AST-113 is a draft). An engineering owner decides whether Text and Heading become server modules with the two consequences above.

Problem and solution fit

  • Why does a server page ship and hydrate Text's code? Each module is 'use client', so the server emits a client reference and the browser loads and hydrates the component.
  • Why does that hurt? Text and Heading are on almost every page, often many times, and every instance hydrates.
  • Why does it matter? Their only client work is truncation, and most renders do not truncate.

Deltas:

  • Primary
    • Text/Text.tsx, Heading/Heading.tsx and Text/index.ts drop 'use client'. They compute the element's props as before and render the plain element or a client part.
    • Text/TruncatableText.tsx (new, 'use client'): the truncation hooks, handlers and tooltip, moved unchanged from Text.tsx and Heading.tsx.
    • Text/TextClampScope.tsx (new, 'use client'): Text's clamp context, moved unchanged from Text.tsx.
    • utils/isReactServer.ts (new): tells a React Server Components render from every other render.
  • Supporting: serverSafeComponents.test.ts lists both client parts as client islands and checks that Text.tsx and Heading.tsx are server modules; serverRender.test.ts and Text/TruncatableText.test.tsx (new); the useTruncation.ts header; a changeset.
  • Tagalongs: none.

Authority

No current record governs React Server Components rendering. AST-113 (#11050) is a draft that records the owner's decision (DEC-1: server builds with small client parts) and lists "FR5 gap: Text and Heading begin with 'use client'". This PR closes that gap and follows FR1, FR2, FR3, FR5, FR6, FR8, FR11 and FR12 for Text and Heading; FR10 holds under webpack and not under Turbopack (above).

Every component contract stays as it is: component:Text FR1 to FR5, AR1, AR2 and PR1 (truncation is measured only with a positive maxLines and the tooltip on), and component:Heading. No behavior change in client renders or in the HTML: the same props, defaults, markup and interaction. The Server Component consequences are listed under Known limitations.

Review receipt: node scripts/review-global-baselines.mjs, authority 7882c6028be5dd71bee7e90eb2b947af16a32a4e, head 65f765a3596e869061369e45186f8e47fd39249a, triggers accessibility, behavior, layout, public-api, theming, react-runtime.

Record Trigger Claims matched Applies to this delta
architecture:public-component-api public-api INV1-INV9, INV12, INV16, INV24, INV25 Yes. Same exports, props, types and defaults; the ref still reaches the element (INV5); TruncatableText, TextClampScope and isReactServer are not exported. No API report row changes.
architecture:react-component-runtime react-runtime INV1-INV6, INV8, INV10-INV13, INV15, INV16, INV18 Yes. The hooks moved unchanged: no new Effect, listener, observer or state; render derives from props and context (INV1).
architecture:component-theming-surface theming INV3-INV10, INV12, INV14, INV15 Unchanged: the text and heading targets, classes and data attributes render as before on both paths.
architecture:internationalization accessibility, behavior, layout, public-api, react-runtime INV1, INV1a, INV2, INV3, INV3a, INV4, INV5, INV7-INV13, INV17 Not touched: Text and Heading translate nothing.
design:bidirectionality accessibility, layout, react-runtime DR1-DR3, DR7-DR12 Unchanged markup, so no direction change.
architecture:component-size-cascade, architecture:container-padding, architecture:layer-runtime, architecture:theme-application, architecture:theme-authoring-contract, architecture:theme-compilation layout, theming, public-api listed claims Not touched.
spec:AST-002, spec:AST-009, spec:AST-012, spec:AST-020, spec:AST-055 to spec:AST-059 public-api, accessibility, behavior, theming listed claims No public input change; accessibility output identical (HTML parity below).

Direct owners resolved first: component:Text and component:Heading. No knowledge record is created or changed.

Change and evidence

Tests

  • serverRender.test.ts (new, 75 tests). It loads React's react-server build and swaps each 'use client' module for a client reference, as an RSC bundler does. react-dom/server cannot load under that condition, so a small resolver renders the tree, as in perf(core): render Text, Heading, Kbd, Button, IconButton and TopNav in React Server Components #8443. Then it loads the client build and the real client parts, and renders the server output as the browser does.
    • isReactServer reads true under the react-server build and false under the client build.
    • Client parts (FR1, FR2): 23 prop shapes, each with the exact client references it must emit: none for 13 shapes without the tooltip (types, sizes, weights, colors, display, justify, wrap, capsize, decorations, as, accessibilityLevel, caller className, style, id, ARIA, data-*, nested elements; maxLines with the tooltip off on Heading and on non-clamping Text); TextClampScope for a clamped Text with the tooltip off; TruncatableText for every explicit maxLines with the tooltip on; plus Link where a Link is nested. Every prop that crosses into a client part is serializable.
    • HTML parity (FR6): for all 23 shapes, the server output rendered with the real client parts is byte-identical to renderToStaticMarkup of the client component.
    • Hydration (FR6): for all 23 shapes, renderToString of the server output, then hydrateRoot with an onRecoverableError handler: no recoverable error, the HTML is unchanged, and it equals renderToString of the client component.
    • First frame (FR6, FR11): plain Text, plain Heading, Text and Heading with the truncation tooltip (with simulated overflow), and a clamped Text with the tooltip off. After hydration, the overflow measurement and the Tooltip module load, every DOM node is the same node as in the server HTML, and the HTML is unchanged; no tooltip layer mounts until the first hover, which then mounts it on the same element. The layout cannot shift, because no element, attribute or text changes. This is a DOM check in jsdom, not a pixel check in a real browser.
  • Text/TruncatableText.test.tsx (new): the remount check above, for Text and Heading.
  • serverSafeComponents.test.ts: TruncatableText.tsx and TextClampScope.tsx are client islands; Text.tsx and Heading.tsx carry no directive and reach no client-only API (a separate check, because Text's folder also holds its client hooks); Text/index.ts and Heading/index.ts carry no directive; a check that a client API exists ('useState' in React) is not a client API call.
  • Mutation-checked: the perf(core): render Text, Heading, Kbd, Button, IconButton and TopNav in React Server Components #8443 rule in client renders fails the remount test; a server render that always takes the client part fails the no-reference cases; a hook added to Text.tsx fails the server-module checks; a clamped Text without TextClampScope fails the nested-Link parity and hydration cases.

Not in this PR (dropped from #8443)

Kbd (PlatformKbd), Button, IconButton, TopNav and TopNavItem, their react-server export conditions and server shells, scripts/sync-exports.js, the pressable split, and __tests__/serverEntryClientParts.ts (it lists react-server entries; Text and Heading have none). This PR is scoped to Text and Heading, phase 1 of AST-113. They read no context on the server path, so one directive-free module serves both environments and needs no separate server entry.

Scope

Components: Text, Heading

  • This PR has one primary intent.
  • Independently removable deltas were removed or split.
  • Public text and artifacts contain no internal Meta context.

Testing

  • pnpm vitest run --project ui on serverRender.test.ts, serverSafeComponents.test.ts, Text/, Heading.test.tsx, Link.test.tsx and Tooltip/: all pass. Also the Table, EmptyState, Banner, Card, List and CommandPalette suites: 27 files, 618 tests pass.
  • pnpm -F @astryxdesign/core typecheck (tsc and the docs typecheck): passes.
  • eslint and prettier --check on every changed file: no errors or warnings. scripts/check-use-client.mjs: passes.
  • The Next.js bundle check above: next build and next build --webpack of the fixture, at main and at this head.
  • pnpm review:pre: 0 findings; merges cleanly into main.
  • Repository pre-commit hooks: pass.
  • Changeset: .changeset/server-render-text-heading.md ([perf], patch).

@vercel

vercel Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Nov 10, 2026 11:36pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Nov 10, 2026
@astracat-bot

astracat-bot Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

AI review status for this pull request.

Review status Updated
❓ Needs maintainer input (for maintainers only) Nov 10, 2026, 11:46 PM UTC

@github-actions github-actions Bot added the needs:design-review Affects visuals — Design should review label Nov 10, 2026
@github-actions

github-actions Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

PR Analysis Report

🔎 Preview · 952673d

Storybook · Sandbox · built from this PR's head

Modified components

Component Size LoC Visual · A11y · RTL
ChatLayout 84.2 kB (+206 B) · 10.5 kB CSS (0) — — · — · —
DropdownMenuSubMenu 71.5 kB (+203 B) · 9.7 kB CSS (0) — — · — · —
lab/EmojiPicker 88.2 kB (+199 B) · 751 B CSS (0) — — · — · —
99 more components
Component Size LoC Visual · A11y · RTL
lab/TransferListSelector 111.3 kB (+197 B) · 1.4 kB CSS (0) — — · — · —
RadioListItem 68.7 kB (+195 B) · 10.1 kB CSS (0) — — · — · —
ChatComposer 79.7 kB (+191 B) · 12.0 kB CSS (0) — — · — · —
ListItem 71.6 kB (+191 B) · 11.4 kB CSS (0) — — · — · —
TabMenu 73.2 kB (+191 B) · 11.1 kB CSS (0) — — · — · —
ChatDictationButton 62.0 kB (+190 B) · 10.1 kB CSS (0) — — · — · —
CheckboxListItem 72.6 kB (+190 B) · 11.4 kB CSS (0) — — · — · —
lab/ChatEmojiPicker 107.6 kB (+190 B) · 773 B CSS (0) — — · — · —
richtext/RichTextView 277.9 kB (+190 B) · 2.3 kB CSS (0) — — · — · —
SideNavHeading 77.0 kB (+189 B) · 11.3 kB CSS (0) — — · — · —
Lightbox 123.9 kB (+188 B) · 10.6 kB CSS (0) — — · — · —
richtext/RichTextEditor 299.8 kB (+186 B) · 2.6 kB CSS (0) — — · — · —
CheckboxList 69.9 kB (+185 B) · 7.7 kB CSS (0) — — · — · —
NumberInput 73.0 kB (+185 B) · 11.4 kB CSS (0) — — · — · —
IconButton 61.5 kB (+184 B) · 10.0 kB CSS (0) — — · — · —
MobileNavToggle 61.8 kB (+184 B) · 10.0 kB CSS (0) — — · — · —
TextInput 69.1 kB (+184 B) · 11.2 kB CSS (0) — — · — · —
ChatToolCalls 33.9 kB (+183 B) · 8.3 kB CSS (0) — — · — · —
DateInput 188.8 kB (+183 B) · 17.0 kB CSS (0) — — · — · —
TopNavHeading 76.6 kB (+183 B) · 11.2 kB CSS (0) — — · — · —
Typeahead 82.0 kB (+183 B) · 12.4 kB CSS (0) — — · — · —
ChatSendButton 61.9 kB (+182 B) · 10.0 kB CSS (0) — — · — · —
InputGroup 57.8 kB (+182 B) · 7.8 kB CSS (0) — — · — · —
Thumbnail 65.8 kB (+182 B) · 11.6 kB CSS (0) — — · — · —
TimeInput 164.0 kB (+182 B) · 16.0 kB CSS (0) — — · — · —
lab/DiffViewer 88.6 kB (+182 B) · 2.1 kB CSS (0) — — · — · —
Popover 92.4 kB (+181 B) · 14.2 kB CSS (0) — — · — · —
Timestamp 34.8 kB (+181 B) · 10.2 kB CSS (0) — — · — · —
BreadcrumbItem 86.0 kB (+180 B) · 12.1 kB CSS (0) — — · — · —
ChatMessageList 30.0 kB (+180 B) · 7.0 kB CSS (0) — — · — · —
TopNavMenu 76.0 kB (+180 B) · 11.2 kB CSS (0) — — · — · —
lab/ChatReactionBar 108.7 kB (+180 B) · 1.1 kB CSS (0) — — · — · —
ChatLayoutScrollButton 62.0 kB (+179 B) · 10.2 kB CSS (0) — — · — · —
Banner 63.4 kB (+178 B) · 10.5 kB CSS (0) — — · — · —
ChatComposerTokenElement 77.5 kB (+178 B) · 11.3 kB CSS (0) — — · — · —
Link 54.2 kB (+178 B) · 7.0 kB CSS (0) — — · — · —
Stepper 63.1 kB (+178 B) · 10.1 kB CSS (0) — — · — · —
Switch 105.0 kB (+178 B) · 9.9 kB CSS (0) — — · — · —
ToggleButton 87.9 kB (+178 B) · 10.1 kB CSS (0) — — · — · —
ChatComposerInput 77.4 kB (+176 B) · 11.3 kB CSS (0) — — · — · —
ComplexSelector 72.3 kB (+176 B) · 11.8 kB CSS (0) — — · — · —
FileInput 70.4 kB (+176 B) · 10.9 kB CSS (0) — — · — · —
Text · Storybook 13.6 kB (+176 B) · 5.4 kB CSS (0) 801 (+84) ✓ · ✓ · —
Button 61.5 kB (+175 B) · 10.0 kB CSS (0) — — · — · —
TableSelectionToolbar 71.7 kB (+174 B) · 13.2 kB CSS (0) — — · — · —
Calendar 72.4 kB (+173 B) · 10.6 kB CSS (0) — — · — · —
SideNavCollapseButton 62.3 kB (+173 B) · 10.0 kB CSS (0) — — · — · —
Carousel 71.2 kB (+172 B) · 10.9 kB CSS (0) — — · — · —
CommandPaletteInput 33.6 kB (+171 B) · 7.5 kB CSS (0) — — · — · —
Timer 15.7 kB (+171 B) · 6.0 kB CSS (0) — — · — · —
lab/TransferList 103.6 kB (+171 B) · 1.2 kB CSS (0) — — · — · —
CheckboxInput 65.5 kB (+169 B) · 9.2 kB CSS (0) — — · — · —
CodeBlock 76.6 kB (+169 B) · 11.3 kB CSS (0) — — · — · —
SideNavItem 71.8 kB (+169 B) · 11.1 kB CSS (0) — — · — · —
Spinner 26.6 kB (+168 B) · 6.2 kB CSS (0) — — · — · —
lab/CommentComposer 153.8 kB (+168 B) · 1.9 kB CSS (0) — — · — · —
BaseTypeahead 73.2 kB (+167 B) · 10.9 kB CSS (0) — — · — · —
TextArea 63.6 kB (+167 B) · 9.3 kB CSS (0) — — · — · —
lab/TabBarMoreList 93.8 kB (+167 B) · 1.8 kB CSS (0) — — · — · —
RadioList 57.5 kB (+166 B) · 7.3 kB CSS (0) — — · — · —
Toast 99.3 kB (+166 B) · 10.3 kB CSS (0) — — · — · —
lab/SelectableCardGroup 65.6 kB (+166 B) · 162 B CSS (0) — — · — · —
lab/ListInput 89.5 kB (+165 B) · 922 B CSS (0) — — · — · —
DateTimeInput 210.4 kB (+164 B) · 18.7 kB CSS (0) — — · — · —
Slider 110.4 kB (+164 B) · 8.8 kB CSS (0) — — · — · —
Tokenizer 93.8 kB (+164 B) · 18.8 kB CSS (0) — — · — · —
TopNavMegaMenu 71.0 kB (+163 B) · 11.8 kB CSS (0) — — · — · —
CommandPalette 74.5 kB (+162 B) · 12.7 kB CSS (0) — — · — · —
DateRangeInput 94.4 kB (+159 B) · 12.5 kB CSS (0) — — · — · —
Field 56.1 kB (+157 B) · 7.2 kB CSS (0) — — · — · —
charts/Chart 206.3 kB (+72 B) · 494 B CSS (0) — — · — · —
charts/ChartTooltip 183.5 kB (+72 B) · 422 B CSS (0) — — · — · —
AlertDialog 106.8 kB (+69 B) · 14.6 kB CSS (0) — — · — · —
Pagination 111.7 kB (+62 B) · 17.8 kB CSS (0) — — · — · —
lab/CommentThread 347.5 kB (+59 B) · 2.4 kB CSS (0) — — · — · —
richtext/RichTextEditorToolbar 280.2 kB (+57 B) · 454 B CSS (0) — — · — · —
lab/Schedule 107.3 kB (+56 B) · 3.9 kB CSS (0) — — · — · —
Heading 14.1 kB (+49 B) · 5.4 kB CSS (0) — — · — · —
AppShell 93.0 kB (+48 B) · 13.5 kB CSS (0) — — · — · —
MoreMenu 98.7 kB (+46 B) · 17.6 kB CSS (0) — — · — · —
DropdownMenu 98.4 kB (+44 B) · 17.6 kB CSS (0) — — · — · —
TableCell 111.5 kB (+36 B) · 17.9 kB CSS (0) — — · — · —
lab/TourStep 98.5 kB (+33 B) · 590 B CSS (0) — — · — · —
lab/DialogHeroHeader 84.3 kB (+29 B) · 372 B CSS (0) — — · — · —
TopNav 73.6 kB (+28 B) · 10.9 kB CSS (0) — — · — · —
charts/ChartLegend 53.4 kB (+27 B) · 224 B CSS (0) — — · — · —
DialogHeader 64.1 kB (+27 B) · 11.5 kB CSS (0) — — · — · —
Selector 101.6 kB (+24 B) · 17.4 kB CSS (0) — — · — · —
SideNav 116.0 kB (+23 B) · 11.4 kB CSS (0) — — · — · —
DrawerHeader 64.3 kB (+22 B) · 12.9 kB CSS (0) — — · — · —
MultiSelector 96.3 kB (+20 B) · 16.8 kB CSS (0) — — · — · —
TableHeaderCell 111.1 kB (+20 B) · 17.6 kB CSS (0) — — · — · —
MobileNav 71.8 kB (+19 B) · 10.6 kB CSS (0) — — · — · —
PowerSearch 291.8 kB (+18 B) · 24.2 kB CSS (0) — — · — · —
Table 127.1 kB (+15 B) · 18.4 kB CSS (0) — — · — · —
Markdown 190.0 kB (+10 B) · 20.7 kB CSS (0) — — · — · —
ContextMenu 110.2 kB (+5 B) · 17.4 kB CSS (0) — — · — · —
lab/LineClamp 15.6 kB (0) · 168 B CSS (0) — — · — · —
lab/Comments 354.4 kB (−2 B) · 2.5 kB CSS (0) — — · — · —

Package size: @astryxdesign/core 7.29 MB packed (+4.3 kB); no new dependencies.

API changes: none in this pull request

Committed API report behind this build: cli 57 rows, core 36 rows; run pnpm api:report.

Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.


Generated by PR Enrichment workflow | View full report

@astracat-bot astracat-bot 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.

Approval waits on an engineering owner's decision, because no current spec record owns the React Server Components boundary that this pull request moves for Text and Heading. An engineering owner approves that boundary or names the record that governs it by commenting /approve-spec <full head SHA> on this pull request (the author may do so, as an engineering owner), and the decision has to cover two consequences for Server Components: passing Text itself as a prop to a client component now fails next build, though it builds on main, and a server re-render that moves maxLines between unset and a number remounts the element.

Required change:

  • The changeset says a Server Component that renders Text or Heading without maxLines "ships no client JavaScript for them", but in a Next.js 16 production build with the default Turbopack bundler such a page still loads the TruncatableText chunks (about 9.1 KB gzip, against 11.3 KB on main, and the same as a page with maxLines={2}), so please narrow the wording in .changeset/server-render-text-heading.md and the Text.tsx and Heading.tsx file headers to what holds, for example that the browser hydrates nothing for them and that a bundler which loads only rendered client modules, such as webpack, loads none of their code.

Also:

  • If the owner accepts the prop-passing change, the changeset should say so.

CI was refused admission on this head ("CI is full"), so please re-run it.

[Automated review]

@astracat-bot astracat-bot 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.

Approval waits on an engineering owner's decision, because no current spec record owns the React Server Components boundary that this pull request moves for Text and Heading. An engineering owner approves that boundary, or names the record that governs it, by commenting /approve-spec <full head SHA> on this pull request (the author may do so as an engineering owner). The decision covers two consequences for Server Components: passing Text or Heading itself as a prop to a client component now fails next build, though it builds on main, and a server re-render that moves maxLines between unset and a number, or turns the tooltip on or off while maxLines is set, remounts the element.

The changeset now matches what each bundler loads, and nothing else blocks; one optional wording suggestion is inline. CI is still running on this head.

[Automated review]

'@astryxdesign/core': patch
---

[perf] Text and Heading render in React Server Components. Their modules no longer carry `'use client'`, so in a Server Component they render on the server and the browser hydrates nothing for them. Only an explicit `maxLines` with the truncation tooltip on renders a client part, which measures overflow and mounts the tooltip, as before; a clamped Text with the tooltip off renders only a small part that tells a nested Link it is in clamped text. A bundler that loads only the client modules a page renders, such as webpack, loads none of their code for a page without truncation; one that loads every client module a page's server code imports, such as Turbopack, still loads the truncation part. Imported from `@astryxdesign/core/Text` or `@astryxdesign/core/Heading`, they render on the server now; imported from the package root, once the root entry is no longer a client module. A Server Component can no longer pass these `Text` or `Heading` themselves as a prop to a client component; import them in the client component instead. In client components, Text and Heading render as before, and a change of `maxLines` or `hasTruncateTooltip` keeps the element and its children mounted. No API changes.

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.

Non-blocking: "loads none of their code for a page without truncation" reads as covering maxLines={0}, which the docs call no truncation. A Server Component page whose only Text is <Text maxLines={0}> (tooltip on by default) renders TruncatableText and downloads its chunk under webpack (about 11 KB gzip in a Next.js 16 build). Consider "for a page whose Text and Heading leave maxLines unset or turn the tooltip off".

imdreamrunner and others added 4 commits November 10, 2026 15:23
Text and Heading carried 'use client' only for truncation: measuring
overflow, the full-text tooltip and, for Text, the clamp context that a
nested Link reads. That work moves into a TruncatableText client part, and
Text.tsx, Heading.tsx and Text/index.ts become server modules.

In a Server Component, Text and Heading without maxLines render the plain
element and reference no client code. Any explicit maxLines, 0 included,
renders the client part. Every other render always takes the client part,
so a change of maxLines or hasTruncateTooltip keeps the element and its
children mounted. utils/isReactServer tells the two apart: React's
react-server build has no useState.

Public APIs and the client output are unchanged. serverSafeComponents.test.ts
lists the client part as a client island and checks that Text.tsx and
Heading.tsx are server modules.

Co-authored-by: Royi Hagigi <[email protected]>
…nt HTML

serverRender.test.ts loads the Text and Heading entries under React's
react-server build, with each 'use client' module swapped for a client
reference, as an RSC bundler does. Without maxLines they render with no
client reference; any explicit maxLines references only TruncatableText,
with serializable props. The test then renders that output with the client
build and the real client part: the HTML equals the client render in every
case, and hydrating it reports no mismatch.

Co-authored-by: Royi Hagigi <[email protected]>
…n part on the server

In a Server Component, Text and Heading now render TruncatableText only for
an explicit maxLines with the truncation tooltip on. With the tooltip off,
Heading and a Text that does not clamp render the plain element. A clamped
Text with the tooltip off renders only TextClampScope, a new client part
that provides the clamp context a nested Link reads, so the Link renders the
same HTML as in the client build. Client renders still always take
TruncatableText.

The changeset and the file headers now say what holds per bundler: webpack
loads none of their code for a page without truncation, and Turbopack still
loads the truncation part that Text imports. The changeset also notes that
a Server Component can no longer pass these Text or Heading as a prop to a
client component.

Co-authored-by: Royi Hagigi <[email protected]>
…e first frame

serverRender.test.ts now lists the exact client references of each prop
shape, nests a Link in clamped and unclamped Text, and hydrates the
renderToString output of the server render. A first-frame check hydrates
plain and truncated Text and Heading and a clamped Text with the tooltip
off. After the overflow measurement and the Tooltip module load, every DOM
node is the node of the server HTML, and only the first hover mounts the
tooltip.

Co-authored-by: Royi Hagigi <[email protected]>

@astracat-bot astracat-bot 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.

Approval waits on an engineering owner's decision, because no current spec record owns the React Server Components boundary that this pull request moves for Text and Heading. An engineering owner approves that boundary, or names the record that governs it, by commenting /approve-spec <full head SHA>; the author can do so as an engineering owner. The decision covers four Server Component consequences: passing Text or Heading itself to a client component fails next build, a re-render that moves maxLines between unset and a number remounts the element, Turbopack still downloads the truncation part with plain Text, and a client parent that clones its child now receives the rendered element instead of Text.

Blocking, independent of that decision:

  • Miss: when a Server Component passes <Text maxLines={1}> or <Heading maxLines={1}> (tooltip on) to a client component that clones its child, such as a Slot or asChild trigger, every prop the parent adds except ref is dropped, because TruncatableText reads only its own props while Text and Heading nest the element's props in elementProps (packages/core/src/Text/TruncatableText.tsx:60-68); pass the element props flat, compose the pointer and focus handlers from them, and add a serverRender.test.ts case that clones the server output.

The earlier note on the changeset's maxLines={0} wording still applies.

[Automated review]

Comment on lines +60 to +68
export function TruncatableText({
as: Component,
elementProps,
maxLines,
hasTruncateTooltip,
isClamped,
ref,
children,
}: TruncatableTextProps) {

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.

In a Server Component, a client parent that clones its child (a Slot or asChild trigger) receives this element for <Text maxLines={1}> or <Heading maxLines={1}>, and every prop it adds except ref is dropped here: handlers, ARIA, data attributes, className and style. In a Next.js 16 build, a cloneElement(child, {'data-state': 'closed', 'aria-describedby': 'tip'}) parent prerenders neither attribute on a truncated Text or Heading, while main (where the child is the Text element) and the plain path keep both. Passing the element props flat would let them through:

export function TruncatableText({as: Component, maxLines, hasTruncateTooltip, isClamped, ref, children, ...elementProps}: TruncatableTextProps) {

with Text and Heading rendering <TruncatableText as={Component} maxLines={maxLines} hasTruncateTooltip={hasTruncateTooltip} ref={ref} {...elementProps}>, plus a serverRender.test.ts case that clones the server output.

This branch was successfully deployed

1 active deployment
Preview — 952673df Deployed Nov 10, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot. needs:design-review Affects visuals — Design should review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant