I think a next.js app is fundamentally slower than a CRA app, why am I wrong /right on this thought? (I am taking about a serverless deployment scenario)
For a CRA created app, it is understandable that the customer gets the first meaningful page slower than the the one from next.js app
— the reason is that a CRA app serves all page assets upfront, but next.js just serves one page
However, after the first page is served, all the other page rendering become the following 2 steps for a CRA app:
1. Browser makes an api calls to the API server;
2. Browser render the page by filling the JSON served from step 1.
For the next.js app though, the process is more expensive in my opinion:
But for a CRA app, step 1 has been down upfront when loading the app (and that’s why the first meaningful page is slow)
So we can clearly see next.js need more time to render a page such as ‘/dashboard’.
Can someone explain to me why people think next.js is more performant than a CRA app?
PS: I am not arguing the value next.js provides such as SEO friendliness; I just want to make sure I understand the performance side of the story clearly
I think slowness here is a perception and tied to an exact deployment of one/both of these options. Both CRA and Next.js are based in React, where Next.js is more of an actual framework and CRA is a pretty vanilla React boilerplate.
My guess is that something is misconfigured somewhere and is causing issues, but is also entirely dependent on implementation. As an example: my own personal website is a React application hosted statically through CloudFront out of an S3 bucket. However, I have some tooling that generates static HTML versions of each page for SEO reasons, but then each page navigation post first load is a client-side render, with some pages fetching additional JSON data and then rendering. This is basically the same as a "live" server-side rendering implementation, just without the server.
This whole process though that you outline for Next.js:
is going to depend on a lot of factors to have it perform well. Its entirely possible to make it fast and seamless if you know what you're doing.