-
I want to write right away that I have begin work with nextjs since version 12. Hello, somebody knows what is it self.__next_f.push in source code. I have not seen this in version 12. |
Beta Was this translation helpful? Give feedback.
Replies: 49 comments 102 replies
-
We're seeing these issue as well. Noticed our bandwidth usage on Vercel jumped by factor because of this. Switching to the /pages directory saw this usage drop to the expected level. Looks to be serialised RSC data, but deleting it from the generated HTML file doesn't cause any issues. @leerob Are you able to offer any insight here? Understand /app isn't stable yet, but haven't seen this raised in the roadmap and currently stands (for us at least!) as the biggest issue for adopting /app dir for larger projects. |
Beta Was this translation helpful? Give feedback.
-
I noticed this today as well... Using next 13.3.1 and all pages use SSG. Tried cleaning up the script tags containing I really hope this is not needed (obviously it is needed now) in the long run. |
Beta Was this translation helpful? Give feedback.
-
This is expected and currently needed by React to "resume" the Server Component tree. In pages/, the duplicate content exists in JavaScript files too so React can hydrate. You can read about Dan's thoughts on that here:
|
Beta Was this translation helpful? Give feedback.
-
Thanks for getting back here @shuding! That makes total sense re: being required to resume the RSC tree. I must have been at the end of the tree in my example, which is why removing that data had no effect. Understand as well that the existing /pages directory has double up here too, however the sticking point for us on this one is that the size of the generated files from an ISR page under /app was much larger than that of the /pages output with ISR. This means the RSC approach incurs a higher bandwidth cost (on a cache miss) with hosts like Vercel when compared with the /pages directory. This seems a little counter intuitive at first glance as the RSC approach will result in sending less to the client. For context, we've had to switch a project back to /pages mid-point here as the scale of the project and heavy usage of ISR tipped our approach in favour of not using RSC which is a shame! Totally understand everything is in flux here, but would be great to know if there are thoughts / awareness around the cost increase for the ISR & RSC combination, and if this is something that might be addressed in the future. |
Beta Was this translation helpful? Give feedback.
-
i get this thing in page source and its also render at homepage but if i reload page its comes actual design comes and then the and homepage also load its real render html |
Beta Was this translation helpful? Give feedback.
-
Hi all, do we have any update on this ? Only this single particular issue makes app routing and React server components not usable. I converted a blog to Next13 App Routing and size of page doubled. |
Beta Was this translation helpful? Give feedback.
-
Would like an update on this. My pages are twice as big now. Is there a fix? |
Beta Was this translation helpful? Give feedback.
-
Is the issue not resolved yet? |
Beta Was this translation helpful? Give feedback.
-
Inside Next.js, we are looking at ways to optimize the inlined payload (for example #52028). However, as I already mentioned above:
This is mainly something that needs to be implemented into React. That said, we will be working closely with the React core team to explore that idea. |
Beta Was this translation helpful? Give feedback.
-
Just to vote up. Will wait fix of that behaviour, because only this one stops us to use Next.js for our production. We hardly working on performance score, and having duplicate data will increase our page weight. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
This makes my CSP fail, is there a good way to get a nonce on these scripts? |
Beta Was this translation helpful? Give feedback.
-
This seems to have gotten much worse in 14. We're seeing ~450 |
Beta Was this translation helpful? Give feedback.
-
Don't know if this applies here too but I haven't even gotten to take a lot of advantage of RSC yet and as soon as I migrated from pages -> app router, my codebase saw pages have their filesize triple or even multiply by 5 times (110kb -> 620kb). Even after lazy loading almost my entire damn application, and doing my best to minimize imports, I have gotten all filesizes back down to 110kb, yet now I have lost 15 performance score on lighthouse from 99 -> 85. Almost as if I was using npm run dev previously. I'm a solo developer on a huge project with over 100,000 lines of code in the codebase and this is affecting performance and stability of the site greatly. Spent almost 12 hours minifying and migrating pages to app router only for it to barely get even close to pages router performance. |
Beta Was this translation helpful? Give feedback.
-
Please solve this issue.. it's affecting our app performance as well. |
Beta Was this translation helpful? Give feedback.
-
If NextJS is a framework for making places to visit on the web (apps, sites, etc) and the page speed is considerably worse than other frameworks used to make websites, it's a problem. Your NextJS website currently has a first-page-load speed penalty. Simple as that. E-commerce experiences rely heavily on SEO-able content, fast loading times AND reactivity. Speed is of the utmost importance. In the case of e-commerce you have to treat every page load as an intent to buy, which means you need as little as possible in the way of doing that, milliseconds count. Customers whose e-commerce sites are built using Next complain the most. It's a little disingenuous to simply handwave away A CORE WEB VITAL STATISTIC as irrelevant because that isn't what Next is for. If Next is dropping support for core web vitals, they should say so. If Next doesn't want to support people building e-commerce solutions, they should remove those examples from the showcase. There is a little ad on the Vercel site saying "NextJs Commerce!" that 100% means this is what Next js is for. I don't see what the confusion is about. |
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
This comment was marked as spam.
-
We are facing the same problem after migrating a large chunk of our components into static components. A major pain point for us is the duplication of large parts of the page. An example in our case is our footer being duplicated into I think an option to have the rsc payload delivered like it happens in adjacent pages (i.e requesting In a more broad context, how is the best way to render HTML with no interactivity? I would have thought RSC would be the best, or am I missing something from the mental model? |
Beta Was this translation helpful? Give feedback.
-
For me the Is there anything I can do about it? So many |
Beta Was this translation helpful? Give feedback.
-
Hi all, I know the discussion topic has been 'closed' and that the majority of the conversation here is surrounding webpage build size etc. I am wondering if the display of raw information inside the self.__next_f.push is a security concern? Let's assume you have sensitive information that you need to display on the client, if this is 'streamed' into the client is there any possibility for sniffers etc to grab that information out of as it is streaming? If this isn't the best place to ask / if its reopened the topic, my bad. Point me in the right direction. Thanks! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
We wanted to migrate to NextJS, but after I've seen that, we decided to postpone that decision. For our product CWV is absolutely important, so I'm waiting fix of duplicating data until we will be ready to migrate to NextJS. |
Beta Was this translation helpful? Give feedback.
-
Every new comment from a new person here makes me a little happier because I hope this issue will soon get the attention it deserves 😅 |
Beta Was this translation helpful? Give feedback.
-
@leerob Is this some kind of React limitation or design decision that it needs |
Beta Was this translation helpful? Give feedback.
-
Hi folks, I work on Next.js and React and I wanted to provide a comprehensive answer to a number of questions related to Is this data necessary?The short answer is: yes For React to be interactive it needs to hydrate in the browser. Before RSC hydration happened by downloading a code bundle which contained all the instructions on how to render the application on the client. While there is some efficiency to be gained by using static bundles it has a huge downside of growing with the scale of the application (there is nuance here for code splitting) and while you may host these static assets on a CDN to make them load faster and with less expensive bandwidth for non-trivial applications you would almost certainly be shipping many more KiB to the browser. You can think of React Server Components as a form of dynamic bundling. A server render produces a set of client code chunks and server HTML markup represented as a tree. This tree conceptually IS the bundle. It's not longer entirely static but was produced at runtime and it needs to be loaded in the browser for hydration to happen. What about MPA mode?One might reasonably ask why we need to send this data if there are no client components. The short answer is Next.js does have a path to having an MPA mode and one could make an RSC framework that was entirely server side but Next.js has not prioritized this because we have more urgent things to focus on at the moment. Next.js is a full stack React framework and while MPA mode is an interesting use case it's not our primary focus so we don't have this yet. What about using the HTML to hydrate?One might also ask if React can just infer the the HTML markup form the HTML itself. One challenge here is we need to discover client components and where they compose within the HTML tree. We could add metadata to the HTML tree to encode this composition but that would add additional bytes and require your SSR'd HTML markup to contain React specific attributes which has it's own downsides. Another way this is potentially problematic is the initial data isn't only hydration data but also potentially interactively loaded UI. If you have a tooltip with hidden content and then a click handler is supposed to reveal that content then that part of the tree won't be in the HTML so we'd have no way to recover it. There are some optimizations React can do to eventually get rid of the hydration data for leaf HTML trees (HTML that has no client components composed within it). The React team work on this someday and for some apps it might have a dramatic effect on the size of the initial data that needs to be sent but we have not started this work yet and don't have an ETA on when we will work on it. For apps that are fairly interactive and have a lot of composed client components this optimization won't have a major impact on the initial data size. What is the best way to load initial data?We've already established that React requires that there be initial data to both hydrate the App and to have the conceptual "bundle" for the page. The next question is what is the best way for Next.js to provide this initial data on document load. Data Consistency and Cache LifetimesOne thing we want to guarantee is that the initial data used to SSR the page exactly matches the initial data we provide React to hydrate the page. The best way to do this is to embed the initial data in the HTML document. If we made a separate resource the HTML document would load we'd need to potentially write the initial data somewhere so it can be fetched but this has infrastructure considerations (what if the write is too slow?, what if the request errors?). We could also just regenerate the initial data and server it in RSC format similar to the RSC responses we get for client navigation. This could work but then we'd render the page twice (worse for compute) and we have the chance that the second version disagrees with the first (what if you used new Date() in your RSC component?). Additionally if we cache the page because it is static we know that the initial data is always cached for the lifetime of the Document itself since it lives within it. If we lifted the initial date out of the Document then we'd have to worry about cache invalidation of our cached initial data being synchronized with the Document cache. Page Performance (Core Web Vitals)The next consideration is page performance. Core Web Vitals are important and we don't want a larger page to block the display of critical visual information. The initial data is streamable and it arrives with a lower priority than visual content. You'll notice that in every HTML Document rendered by Next.js there is always the HTML "shell" first which is the Document head and body along with either the entire page content (if nothing suspended or you did not defined any loading states using Suspense) or some page content with loading states (if using Suspense to take advantage of server streaming rendering). If there is additional HTML to stream in Next.js will prioritize it over this initial data as well. The only time initial data is sent is when the render is waiting on IO to continue revealing additional visual content and we can emit some of the initial data to maximally use available bandwidth. It should be noted as well that for static responses we always produce a complete HTML document first and append the initial data at the end. What does this mean for Core Web Vitals? The initial data is never in front of visually relevant content so the browser can parse and render the incoming HTML as fast as it is received. Whether the initial data arrives alter in the stream or independently as a subresource request has no bearing on FCP or LCP. In fact it actually can help because if we did a concurrent subresource request it might inappropriately starve bandwidth from critical resources for loading such as stylesheets and fonts. By encoding the initial data into the Document itself we can ensure it arrives at the lowest priority, never blocking other resource loading and never blocking visual HTML. There is a related concern which is Page Weight. There is a notion that CWV suffer if page weight is bigger. This is only true via correlation in that bigger pages have more "stuff to load" generally and loading more stuff takes more time. But the extra page weight for initial data is not "stuff to load" and so each additional byte has no bearing on CWV. Page Weight is not a direct actor on CWV it's simply an indirect indicator of other stuff that might affect CWV so if you want to investigate CWV performance you need to look at things like your data fetching on the server, your ability to cache, whether your static assets are appropriate sized (optimized images for instance) or whether your fonts are being preloaded properly and discovered early. Future React direction for initial dataIn the future React will support first class support for initial data. It is such a common practice that you want your hydration to see what your SSR pass saw that it ought to be embedded directly in React itself. This means in the future there will be no SummaryReact requires hydration for interactivity. This is just part of React's model and not something Next.js is in a position to alter. React Server Components are a form of dynamic bundling so initial data for hydration (and updates) is no longer statically serveable by CDN assets exclusively. This has tradeoffs but the bet React is making is that request specific dynamic bundles are better for most apps most of the time especially as they grow in size and complexity. Next.js is not in a position to alter this because it is inherent to the RSC model. Next.js is optimized to provide the best possible CWV by streaming in initial data late and at low priority relative to subresource and HTML which have a big impact on CWV results. Encoding the initial data into the HTML Document is not only not bad it's specifically good and better than all the other options. The reason pages router or non RSC frameworks don't have a similar feature in their document streaming is the initial data is entirely static (it's bundler chunks) which while nice that is is static suffers from the inability to scope the "bundle" to what was rendered (allowing for nuances like code splitting) There are some optimizations that React can make to shrink the size of the RSC tree but these optimizations will reduce the size of the initial data not eliminate it's need for existing in the first place. It's a quantitative change not a qualitative one React believes in the model of embedding initial data into the HTML Document so much that it will eventually implement this into the framework itself so every SSR supporting React project doesn't have to implement this kind of thing itself. (Note that this isn't limited to RSC initial data, it could be things like i18n translations or any other data used during SSR that should be available on the client during hydration) |
Beta Was this translation helpful? Give feedback.
-
Moving to Astro. Thanks for those amazing years 🫡 ! |
Beta Was this translation helpful? Give feedback.
-
Same problem on our big statically exported site (7K pages), I have spent the last two weeks migrating all the application to app directory and making use of RSC for a web performance / seo taskforce only to see our Core Web Vitals getting worse. I'm sad... |
Beta Was this translation helpful? Give feedback.
-
@gnoff great article above, hoping you may have some insight on the following post, as it seems this additional hydration data is causing serious issues with Review structured data, resulting in Google not displaying them many thanks for your time |
Beta Was this translation helpful? Give feedback.
-
Hi all, could you please help me with this issue. I tried to use google search console for SEO but this happen because of self.__next_f.push. Anyone can help me to disallow unwanted url to crawled by google search console? Thank you |
Beta Was this translation helpful? Give feedback.
Hi folks, I work on Next.js and React and I wanted to provide a comprehensive answer to a number of questions related to
__next_f.push
Is this data necessary?
The short answer is: yes
For React to be interactive it needs to hydrate in the browser. Before RSC hydration happened by downloading a code bundle which contained all the instructions on how to render the application on the client. While there is some efficiency to be gained by using static bundles it has a huge downside of growing with the scale of the application (there is nuance here for code splitting) and while you may host these static assets on a CDN to make them load faster and with less expensive bandwidth for non-trivial …