Question: is it possible to use with getStaticProps()?
See original GitHub issueDear Adam,
Thank you for this wonderful package. Please feel free to ignore this question if it is silly. I am struggling to follow what is going on…
We are using your package and would like to fetch data in getStaticProps() (in conjunction with the next-mdx-remote package.)
I found this thread and noticed you had commented on it.
Am I right in thinking that in order to fetch data in getStaticProps(), we cannot use your package, and will instead have to try to copy one of the solutions in that thread?
Thank you so much for any pointers and have a lovely Christmas,
Lydia
Issue Analytics
- State:
- Created 3 years ago
- Comments:16 (7 by maintainers)
Top Results From Across the Web
use getStaticProps in component - Stack Overflow
Here's a possible solution: Using a node script (like predev) to fetch your content and store it in JSON files in your project, ......
Read more >Next.js getStaticProps() Function - GeeksforGeeks
Step 1: To create a NextJS project, run the following commands on terminal · Step 2: Open your project files on your desired...
Read more >getStaticProps on _app · Discussion #10949 · vercel/next.js
Inside the app/ directory, there is a powerful new way to fetch data with React's use() hook and the extended Web fetch() API....
Read more >Data Fetching: getStaticProps - Next.js
getStaticProps does not have access to the incoming request (such as query parameters or HTTP headers) as it generates static HTML. If you...
Read more >getStaticProps vs getServerSideProps for Next JS - OhMyCrawl
NextJs ships with two methods for accomplishing this work on the server: getStaticProps() and getServerSideProps(). These methods can be included in any ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

There are enough requests going on with your network history there that I can’t really trace it down easily, but I think I know what’s going on there. Actually, the experience you’re describing indicates that the library isn’t actually using the SSG data on route transitions.
When you load the statically generated page, the data doesn’t exist in the cache, so Apollo fills it in with a network request. That’s why you see the spinner. If that page used the SSG data, there wouldn’t be a spinner because the data from the SSG function populates synchronously. The second time you load the page, the server data has populated the cache, so it loads synchronously in your case as well. After the cache has been populated, both versions are indistinguishable in your case: it’s just the first load that changes.
In your case, the app is functional, but takes an extra network request the first time those pages load. If an app only uses SSG and has no live endpoint, they can’t use links from ‘next/link’ for fast routing, and would have to use
<a />tags to flush the document and start again with the new SSG data.Gotcha. Sorry for dropping off.
So I’m using next-apollo-ts on one of my projects and for some reason, the cache works as expected when navigating between a page rendered using SSG and another rendered client-side.
Notice when you click the first row on the table of this statically generated page you’ll see a spinner. When you go back to the “orchestrators” page and then click the first row again and it gets served from apollo’s cache and there’s no spinner. I can’t explain why but it seems to be working as it should. 🤷