What is the difference of using initializeApollo on getStaticProps #14104
-
I saw this on the next.js/examples/api-routes-apollo-server-and-client/pages/index.js Lines 32 to 44 in 89fffa6 But on the But in both in the What about the usage of What are the differences of doing the redirect directly in the page, calling |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
@lfades Sorry for pinging you here but I guess that you were the one that made the example. If you can explain I would appreciate a lot, it would help me a lot. |
Beta Was this translation helpful? Give feedback.
-
Hi @zefexdeveloper this is a very good question. I'll try to give you a very detailed answer 😌
About Now why is |
Beta Was this translation helpful? Give feedback.
Hi @zefexdeveloper this is a very good question. I'll try to give you a very detailed answer 😌
api-routes-apollo-server-and-client
is usinggetStaticProps
inpages/index.js
to add Static Generation to the page, this is good because the data for the page in this case is known at build time, therefore we can pregenerate the page and serve the same static files to the users using the site.About
_app.js
, in both examples, and in all Apollo examples, takes care of starting the global Apollo client that can be used for all pages, it w…