Replies: 4 comments 25 replies
-
Covered quite a bit in #10920 (comment)
In many of the cases where we see Next.js used there has to be some kind of caching layer as the data is not "live", eg it comes from a CMS that changes less than once per 1 second. At ZEIT the full dashboard is static. If a page does require live data we client-side render it using: https://swr.now.sh/. |
Beta Was this translation helpful? Give feedback.
-
I know but the example is written this way to mimic api calls. To closely match the architecture we have: REST api's. |
Beta Was this translation helpful? Give feedback.
-
Thanks I'll try to modify the example to hook up with a real external API to check the real-world impact. |
Beta Was this translation helpful? Give feedback.
-
Hi In our case, NextJS website is running under www.example.com and all our APIs are served separately under, api.example.com (with appropriate CORS headers enabled). Also, api.example.com has it's own caching strategy enabled. As new version of NextJS recommend using Also, reading multiple issue threads in Github gave us an understanding that, So my concern is, the use case for So my understanding is =>
Please correct me if I'm wrong. |
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.
-
Hi,
So I've created a little demo to show-case all the different ways NextJS can do page-rendering: [csr, ssr, ssg].
You can find that demo here: https://static-next.willemliu.now.sh/
Code here: https://github.com/willemliu/static-next
In the NextJS documentation the following recommendation can be found:

However I've found a significant performance penalty in using
getServerSideProps
vsgetInitialProps
You can check for yourself by navigating between
SSR
andHybrid-SSR
in the demo mentioned above.SSR
implementsgetServerSideProps
andHybrid-SSR
implementsgetInitialProps
.Both do exactly the same.
It seems to me that the penalty comes from the extra roundtrip to the lambda
getServerSideProps
of that page upon navigation. Where withgetInitialProps
the client-side code runsgetInitialProps
and does the data fetching directly.Knowing this, my question is what are the benefits of implementing
getServerSideProps
vsgetInitialProps
?Beta Was this translation helpful? Give feedback.
All reactions