Why is a page with only client components requesting a RSC Payload? #67401
Replies: 2 comments 3 replies
-
|
Your layout root is a server component to start and I think there are a few others spaced in there |
Beta Was this translation helpful? Give feedback.
-
|
The answer is that even if you place "use client" at the very top of your component tree, including your root layout.tsx, the Next.js server is still fundamentally involved in every navigation, and an RSC payload will still be requested. The App Router's Core Philosophy: Server-Driven Navigation The Next.js App Router is not a traditional Single-Page Application (SPA) router that operates exclusively in the browser. It is a server-centric router that uses React Server Components as its underlying primitive. Think of it this way: the "use client" directive does not turn off the RSC architecture. Instead, it acts as a boundary marker that tells the server: "Stop rendering on the server at this point. Instead, send a placeholder and a reference to a JavaScript bundle that the client should download and execute."
|
Beta Was this translation helpful? Give feedback.



Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
I am trying to understand a performance issue when using only React Client Components on a page (+ App Router). It's a list-detail page. When I click on different items in the list, the client hits the Next.js server for an RSC Payload on every click. I don't understand why.
I would have assumed that all code for that page should be on the client after the first render, and from then on, the client would not have to load anything from the server. Can anyone help me understand this behavior and a potential workaround?
Please see details below.
My Use Case
Here's a screenshot of my POC – a movie list on the left and the selected movie's detail on the right. Granted this is not fast changing data, but it will do for the POC 😃
Implementation Details
I have implemented the requirements 4 ways to compare the performance:
undefined(see here). This allows us to maintain the URL structure as/movies/id, but serve the detail as a hard-coded child (see here).Also, to meet the requirements, I have done the following:
no-storeoption – see here.Example
Steps to Reproduce
Given that Client Components is my preferred option (option 2), let's first demonstrate the issue.
Inspect).Networktab.Client Componentstab. The movie list appears on the left. The initial display may be slow because the API server may be cold starting, however subsequent loads should be fast.Analysis
Again, this analysis is focused on the Client Components option (option 2).
'use client'– see here.'use client'– see here.In spite of this entire page consisting of client components only, the browser is making two network calls on each movie click:
See the Chrome Dev Tools snapshot below for clarity:
I can understand if the RSC Payload is requested just the first time a movie is clicked. However, for subsequent clicks, we shouldn't have to download the RSC payload again because we are rendering the same client component repeatedly (just with different data). We are wasting 572 ms per click!
I would love to get (1) an explanation of why this behavior is happening and (2) a workaround where all we see is one call to the API server for each click.
This is hampering my ability to deliver a responsive user interface for this use case with Next + RSC. This would be a no-brainer to implement as a traditional React SPA.
Beta Was this translation helpful? Give feedback.
All reactions