| | |

React Server Components 27 🧬 Performance Auditing — Measuring payload size and hydration cost

⏱️ Estimated read: 15 min | |

RSC performance auditing is not the same as auditing a client-rendered application. The client bundle is only one of two payloads that cross the network. The other is the RSC payload—the serialized Flight stream that contains the rendered Server Component output and the client references that tell the browser which chunks to load. A page can have a small client bundle and a large RSC payload, or a large client bundle and a small RSC payload, and the two sizes are measured with different tools and fixed with different techniques. The hydration cost is a third metric, and it is determined by the client bundle’s size and the number of interactive islands, not by the RSC payload at all.

The auditing workflow has three layers. The bundle analyzer shows which modules are in the client graph and why. The network inspection shows the RSC payload size and composition. The field or lab metrics show the user-facing consequence: LCP, INP, and the time to hydration. The layers are connected—a large client bundle delays hydration, and a large RSC payload delays the first contentful paint—but the tools for each layer are separate .

Key point: The RSC payload is the Flight stream, not the client JavaScript bundle. Measure it with the network tab filtered to ?_rsc= or a Chrome extension like RSC Viewer, not with the bundle analyzer. Measure the client bundle with the framework’s analyzer. Measure hydration cost with performance traces or field data, not with either size metric alone.


Why the audit needs three layers

The bundle analyzer answers “what is in the client graph.” The Next.js Turbopack analyzer (next experimental-analyze) or the Webpack analyzer (@next/bundle-analyzer) shows the client modules and their import chains. The first question for any large module is not “how do I split it” but “why is it in the client graph at all” . A charting library in the client bundle is a problem only if a Client Component imports it. A Client Component that imports it is a problem only if the component is not actually interactive. The analyzer makes the import chain visible.

The RSC payload is a separate measurement. The Flight stream is the serialized output of the Server Components. It contains the rendered markup, the client references, and the serialized props. It does not contain the client JavaScript. The payload is measured in the network tab, filtered to the ?_rsc= requests, or by fetching the stream directly with curl -s -H "RSC: 1" "https://localhost:3000/en/?_rsc=1" | wc -c . The RSC Viewer Chrome extension parses the Flight wire format and breaks down the payload by row type, which shows whether the bytes are markup, client references, or serialized props .

Hydration cost is the time, not the size. Hydration is the process of attaching event handlers to the server-rendered markup. The cost is determined by the amount of client JavaScript and the number of interactive islands, not by the RSC payload. A page with a large RSC payload and a small client bundle has a fast hydration. A page with a small RSC payload and a large client bundle has a slow hydration. The measurement is a performance trace or a field metric (INP, TBT), not a bundle size .


a. Measuring the RSC payload

The RSC payload is the Flight stream. It is served on the initial HTML request and on every client-side navigation as a separate ?_rsc= request. The size of the stream is the size of the rendered output plus the serialized props plus the client references.

# Measure the raw RSC payload size with curl.
# The RSC: 1 header requests the Flight stream instead of HTML.
curl -s -H "RSC: 1" "https://localhost:3000/en/?_rsc=1" | wc -c

The curl command returns the raw byte count. The unit is bytes; divide by 1024 for kilobytes. The payload is usually compressed in transit, so the wc -c count is the uncompressed size. The network tab shows the compressed transfer size, which is the number that matters for the user’s download .

// Measure the RSC payload size from the browser console.
// The Flight records are embedded in <script> tags.
// The heuristic matches the element tuple format: ["$","div",...]
const scripts = document.querySelectorAll('script');
let rscPayloadSize = 0;

scripts.forEach((script) => {
  if (script.textContent && /\["\$","[a-zA-Z]/.test(script.textContent)) {
    rscPayloadSize += new Blob([script.textContent]).size;
  }
});

console.log(`RSC payload: ${(rscPayloadSize / 1024).toFixed(1)} KB`);

The console heuristic is an approximation. It matches the Flight element tuples that are embedded in the initial HTML. The RSC Viewer extension is the more precise tool: it parses the wire format and shows the breakdown by row type, including the resource size and the transferred (compressed) size .

The payload composition matters more than the total size. A payload that is mostly markup is a payload that the server is rendering correctly. A payload that is mostly client references is a payload that is telling the browser to load many chunks. A payload that is mostly serialized props is a payload that is passing too much data across the boundary. The rsc-contract static analyzer estimates the boundary payload and enforces a budget, but the estimate is static, not a runtime Flight measurement .


b. Measuring hydration cost

Hydration cost is the time between the server-rendered HTML being visible and the page becoming interactive. It is measured with a performance trace or with field metrics. The trace shows the JavaScript execution time after the HTML is parsed; the field metric (INP or TBT) shows the consequence for the user.

// Measure hydration time with the Performance API.
// The 'navigation' entry provides the timing after the document is parsed.
const [navigation] = performance.getEntriesByType('navigation');

// domInteractive is when the HTML is parsed.
// domContentLoadedEventEnd is when the deferred scripts have executed.
// The difference approximates the hydration window.
const hydrationWindow = navigation.domContentLoadedEventEnd - navigation.domInteractive;

console.log(`Hydration window: ${hydrationWindow}ms`);

The window is an approximation. It includes the download and execution of the client bundle, which is the dominant cost. The more precise measurement is a performance trace with the “Interactions” track, or a Lighthouse run that reports TBT (Total Blocking Time) and INP (Interaction to Next Paint). The academic evaluation of RSC performance measured hydration time directly and found that RSC reduces the client JavaScript payload and improves initial rendering, but the hydration cost remains a bottleneck for the interactive islands that do exist .

// Measure the number of interactive islands.
// Each 'use client' boundary is an island.
// The count is a proxy for the hydration cost.
// A high count with a small total bundle is still a hydration cost.
// The count is not a size metric; it is a structural metric.

The island count is not a substitute for the timing measurement. A page with one large Client Component and a page with fifty small Client Components can have the same bundle size and different hydration costs. The first hydrates one component; the second hydrates fifty. The number of boundaries is the structural metric, and the trace is the timing metric.


Complete Example Session

// ============================================
// PART 1: THE BUNDLE ANALYZER BASELINE
// ============================================

// Run the analyzer on the production build.
// Turbopack:
// npx next experimental-analyze --output
// Webpack:
// ANALYZE=true npm run build

// Save the output for comparison.
// cp -r .next/diagnostics/analyze ./analyze-before

// The analyzer shows the client modules and their import chains.
// The first question: which 'use client' file pulled this in?

// ============================================
// PART 2: THE RSC PAYLOAD BASELINE
// ============================================

// Measure the raw payload with curl.
// curl -s -H "RSC: 1" "http://localhost:3000/?_rsc=1" | wc -c
//
// Measure the compressed payload in the network tab.
// Filter the requests to ?_rsc= and read the transferred size.
//
// The two numbers are different.
// The curl number is uncompressed; the network number is compressed.

// ============================================
// PART 3: THE HYDRATION BASELINE
// ============================================

// Run a Lighthouse performance audit.
// Record TBT and INP.
// Record the total client JavaScript size.
//
// The hydration cost is the JavaScript execution time,
// not the bundle size alone.
// A 200KB bundle that executes for 500ms is worse than
// a 300KB bundle that executes for 200ms.

// ============================================
// PART 4: THE LEAK — A CLIENT COMPONENT AT THE ROOT
// ============================================

// app/page.jsx
'use client';
import { Chart } from 'recharts'; // 120KB client bundle
import { formatDate } from 'date-fns'; // 70KB client bundle

export default function Page() {
  // The entire page is a Client Component.
  // The chart and date libraries are in the client bundle.
  // The RSC payload is small (no server rendering).
  // The client bundle is large.
}

// ============================================
// PART 5: THE FIX — THE LEAF BOUNDARY
// ============================================

// app/page.jsx
import { db } from '@/lib/db';
import { formatDate } from 'date-fns'; // server-only
import { ChartWrapper } from './chart-wrapper'; // the client leaf

export default async function Page() {
  const data = await db.query('SELECT * FROM metrics');
  // The page is a Server Component.
  // The RSC payload is larger (the server renders the markup).
  // The client bundle is smaller (only ChartWrapper).
  return (
    <div>
      <h1>Metrics</h1>
      <ChartWrapper data={data} />
    </div>
  );
}

// ============================================
// PART 6: THE MEASUREMENT AFTER THE FIX
// ============================================

// Re-run the analyzer.
// The chart and date libraries are no longer in the client graph.
// The client bundle is smaller.
//
// Re-measure the RSC payload.
// The payload is larger because the server is rendering the markup.
// The payload size is the trade-off for the smaller bundle.
//
// Re-run Lighthouse.
// The TBT and INP should improve because the client JavaScript is smaller.

// ============================================
// PART 7: THE PAYLOAD COMPOSITION
// ============================================

// Use RSC Viewer to break down the payload.
// The rows are categorized by type:
// - Element tuples (markup)
// - Client references
// - Serialized props
// - Module metadata
//
// A payload dominated by element tuples is a payload
// that is rendering a lot of markup.
// A payload dominated by client references is a payload
// that is loading many chunks.
// A payload dominated by serialized props is a payload
// that is passing too much data across the boundary.

// ============================================
// PART 8: THE HYDRATION TRACE
// ============================================

// Record a performance trace in Chrome DevTools.
// The "Interactions" track shows the hydration time.
// The "Main" track shows the JavaScript execution.
//
// The hydration time is the gap between
// the HTML being parsed and the first interaction being handled.
// A long gap is a hydration cost.

// ============================================
// PART 9: THE BUDGET
// ============================================

// rsc-contract enforces static budgets for the boundary payload.
// rsc-contract.config.mjs
// import { defineConfig } from 'rsc-contract';
// export default defineConfig({
//   budgets: {
//     rscPayload: '200kb',
//     clientBoundary: '50kb',
//   },
// });

// The budget is an estimate, not a runtime measurement.
// It catches regressions before the build ships.

// ============================================
// PART 10: THE VERIFICATION CHECKLIST
// ============================================

// [ ] The bundle analyzer output is saved as a baseline.
// [ ] The RSC payload size is measured with curl and the network tab.
// [ ] The payload composition is inspected with RSC Viewer or a parser.
// [ ] The hydration time is measured with a performance trace.
// [ ] The 'use client' boundaries are at the leaves.
// [ ] The client bundle contains only the code that needs to run.
// [ ] The payload budget is enforced in CI if the project has one.

The ten parts covered the baseline measurements, the root-level leak, the leaf fix, the payload composition, the hydration trace, and the budget. The through-line is that the RSC payload and the client bundle are different measurements, and the audit must track both.


Quick Reference

The measurement tools

MetricToolUnit
Client bundle sizenext experimental-analyze / @next/bundle-analyzerBytes
RSC payload sizecurl -H "RSC: 1" / network tab ?_rsc=Bytes
RSC payload compositionRSC Viewer / rsc-contract (static estimate)Categories
Hydration timePerformance trace / Lighthouse TBT/INPMilliseconds
Boundary payload budgetrsc-contractBytes (estimated)

The leak vs fix trade-off

PatternClient bundleRSC payloadHydration
'use client' at rootLargeSmallSlow
'use client' at leafSmallLargerFast

The payload targets

TargetValueSource
HTML size< 500KBCommunity benchmark
RSC push calls< 70 (prefer < 40)Community benchmark
Client island size< 50KB@rsc-xray threshold
Boundary payloadConfigurablersc-contract budget

Best Practices

✅ Do This:

# Save the analyzer output before refactoring
npx next experimental-analyze --output && cp -r .next/diagnostics/analyze ./before
// Filter the RSC requests in the network tab
// ?_rsc= requests are the Flight streams
// Measure the payload composition with RSC Viewer
// The row-type breakdown shows what is in the payload

❌ Don’t Do This:

// Use the bundle analyzer to measure the RSC payload
// The analyzer shows client JavaScript, not Flight   // ❌

// Use the RSC payload size as a proxy for hydration cost
// Hydration is a time metric, not a size metric      // ❌

// Assume a smaller bundle always improves LCP
// Moving presentational components to the client can reduce
// the payload but delay LCP if the LCP element is in the moved
// component                                         // ❌

Common Pitfalls

PitfallWhy It HappensFix
Payload size is not improving after fixing the bundleThe RSC payload was never measuredMeasure with curl and the network tab
Hydration is slow despite a small bundleMany interactive islandsCount the 'use client' boundaries; consolidate or defer
The analyzer shows a module that should not be thereThe 'use client' boundary is too highTrace the import chain to the boundary
The payload is large but the bundle is smallToo much serialized data or markupInspect the composition with RSC Viewer
The payload budget fails in CIA new prop or component increased the boundaryCheck the diff against the baseline

Real-World Examples

1. Measure the payload with curl

curl -s -H "RSC: 1" "http://localhost:3000/?_rsc=1" | wc -c

2. Filter the network tab

// Filter to ?_rsc= to see the Flight streams

3. Save the analyzer baseline

npx next experimental-analyze --output

4. Inspect the payload with RSC Viewer

// The DevTools panel lists every RSC request and the byte breakdown

5. Measure the hydration window

const [nav] = performance.getEntriesByType('navigation');
const window = nav.domContentLoadedEventEnd - nav.domInteractive;

6. Count the client boundaries

// Each 'use client' file is an island
// A high count is a structural hydration cost

7. Enforce a payload budget

// rsc-contract.config.mjs
budgets: { rscPayload: '200kb', clientBoundary: '50kb' }

8. The leak

'use client'; import { Chart } from 'recharts'; // root-level

9. The fix

// Server Component fetches; Client Component renders the chart leaf

10. The trade-off

// Smaller bundle, larger payload, faster hydration

Visual

The Three Measurements

┌──────────────────────────────────────────────────────────────┐
│  CLIENT BUNDLE VS RSC PAYLOAD VS HYDRATION                     │
│                                                              │
│  Client bundle              RSC payload                     │
│  ┌─────────────────────┐   ┌─────────────────────┐         │
│  │ JavaScript          │   │ Flight stream       │         │
│  │ Downloaded by       │   │ Markup + props +    │         │
│  │ the browser         │   │ client references   │         │
│  │                     │   │                     │         │
│  │ Measured by:        │   │ Measured by:        │         │
│  │ bundle analyzer     │   │ curl / network tab  │         │
│  └──────────┬──────────┘   └──────────┬──────────┘         │
│             │                          │                     │
│             └──────────┬───────────────┘                     │
│                        │                                     │
│                        ▼                                     │
│             ┌─────────────────────┐                         │
│             │ Hydration time      │                         │
│             │                     │                         │
│             │ JavaScript execution│                         │
│             │ after HTML parse    │                         │
│             │                     │                         │
│             │ Measured by:        │                         │
│             │ trace / Lighthouse  │                         │
│             └─────────────────────┘                         │
│                                                              │
│  Three different metrics, three different tools.            │
└──────────────────────────────────────────────────────────────┘

The Boundary Placement Trade-off

┌──────────────────────────────────────────────────────────────┐
│  ROOT VS LEAF BOUNDARY                                        │
│                                                              │
│  Root boundary                  Leaf boundary               │
│  ┌─────────────────────┐       ┌─────────────────────┐     │
│  │ 'use client'        │       │ Server Component    │     │
│  │ Page                │       │ Page                │     │
│  │ ├── Chart (client)  │       │ ├── ChartWrapper    │     │
│  │ ├── Formatter       │       │ │   ('use client')  │     │
│  │ └── Date lib        │       │ └── Formatter       │     │
│  │                     │       │     (server)        │     │
│  │ Bundle: large       │       │ Bundle: small       │     │
│  │ Payload: small      │       │ Payload: larger     │     │
│  │ Hydration: slow     │       │ Hydration: fast     │     │
│  └─────────────────────┘       └─────────────────────┘     │
│                                                              │
│  The trade-off is explicit.                                │
│  The audit measures both sides.                             │
└──────────────────────────────────────────────────────────────┘

The Payload Composition

┌──────────────────────────────────────────────────────────────┐
│  WHAT IS IN THE FLIGHT STREAM                                 │
│                                                              │
│  ┌──────────────────────────────────────────────┐           │
│  │ Element tuples (markup)                      │           │
│  │ Client references (chunk URLs)               │           │
│  │ Serialized props (data)                      │           │
│  │ Module metadata                              │           │
│  └──────────────────────────────────────────────┘           │
│                                                              │
│  A payload dominated by element tuples is a server-         │
│  rendered page.                                              │
│  A payload dominated by client references is a page with    │
│  many interactive islands.                                   │
│  A payload dominated by serialized props is a page that     │
│  is passing too much data across the boundary.              │
└──────────────────────────────────────────────────────────────┘

Summary

ItemValue
Client bundle measurementnext experimental-analyze / @next/bundle-analyzer
RSC payload measurementcurl -H "RSC: 1" / network tab ?_rsc=
Payload compositionRSC Viewer Chrome extension
Hydration measurementPerformance trace / Lighthouse TBT/INP
Boundary budgetrsc-contract (static estimate)
Root boundary costLarge client bundle, slow hydration
Leaf boundary costSmall client bundle, larger RSC payload
Payload targetsHTML < 500KB, RSC push calls < 70

Key takeaways:

  • The RSC payload and the client bundle are different measurements. The bundle analyzer shows the client JavaScript. The Flight stream is the RSC payload, and it is measured with the network tab or curl. A page can have a small bundle and a large payload, or the reverse, and the fixes are different .
  • The boundary placement determines the trade-off. A 'use client' directive at the root pulls the entire subtree into the client bundle, which slows hydration. The same directive at the leaf keeps the bundle small and moves the rendering to the server, which increases the RSC payload but reduces the client JavaScript .
  • Hydration is a time metric, not a size metric. The hydration cost is the JavaScript execution time after the HTML is parsed, and it is measured with a performance trace or a field metric. A page with a small bundle and many islands can have a slower hydration than a page with a larger bundle and one island .
  • The payload composition matters more than the total size. A payload dominated by markup is a server-rendered page. A payload dominated by client references is a page with many chunks. A payload dominated by serialized props is a page passing too much data across the boundary. RSC Viewer or a Flight parser shows the breakdown .
  • The audit is a before-and-after comparison. Save the analyzer output, the payload size, and the hydration trace before the refactor. Re-run all three after. A change that reduces the bundle but increases the payload is a trade-off that must be measured, not assumed .

Remember: RSC performance auditing is not a single measurement. It is three: the client bundle, the RSC payload, and the hydration time. The bundle analyzer answers “what JavaScript is shipping.” The network inspection answers “what Flight stream is crossing.” The performance trace answers “how long does the browser take to become interactive.” The first question for any large module is not “how do I split it” but “why is it in the client graph at all.” The first question for any large payload is not “how do I compress it” but “what is in it.” The audit is the discipline of measuring all three, and the fix is the discipline of placing the boundary at the leaf.

Was this helpful?


Stop using slow, ad-bloated tool sites! 🤮

🔎 Search “KandZ Tools” on Google to use many professional utilities for free.

KandZ.me is the ultimate minimalist hub for:
✅ Finance (Mortgage, Interest, Inflation)
✅ Tech (Base64, JSON, Dev Suite, IP)
✅ Health (BMI, BMR, TDEE)
✅ Productivity (Timer, Workspace, QR)

⚡️ Fast & Private
🔒 No data leaves your device
💎 100% Free

🔗 Use it now: https://tools.kandz.me
🔖 Bookmark it—you’ll need it later!