Why is a page with only client components requesting a RSC Payload? #7352
Replies: 2 comments 2 replies
-
Sorry, posted this in the wrong location |
Beta Was this translation helpful? Give feedback.
2 replies
-
This discussion was automatically locked because the community moved to a new site. Please join us at vercel.community |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Summary
I am trying to understand a performance issue when using only React Client Components on a page (+ App Router). It's a master-detail page. When I click on different items in the master 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 then on client should not have to load anything from the server. Any help in understanding this behavior and a potential workaround would be very helpful.
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-store
option – see here.Example
https://nextjs-nested-layouts-ruby.vercel.app/
Steps to Reproduce
Given that Client Components is my preferred option (option 2), let's first demonstrate the issue.
Inspect
).Network
tab.Client Components
tab. 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:
The first call to get an RSC Payload seems completely unnecessary for every click. We are wasting 572 ms per click! Since we are rendering the same client component repeatedly (just with different data), we shouldn't have to download the RSC payload again and again. I can understand if this Payload is requested just the first time a movie is clicked.
I would love to get a good explanation of this behavior and a workaround if possible. All we should see is one call to the API server for each click. What I am asking for seems reasonable – it would be a no-brainer to implement it as a traditional React SPA!
Beta Was this translation helpful? Give feedback.
All reactions