Feature Request: Show loading indicator while getInitialProps() is running
See original GitHub issueThe way I understand the loadingComponent
prop, it is only shown if the target screen is configured to return null.
Is is possible to show the loading indicator while getInitialProps
of the loading screen is executing? This would allow to use the indicator without specifically handling serverside and clientside handling.
I would assume that it is possible by hooking into next.js router events. However, I think that the problem might be with triggering the transition before the new component exists.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Add a loading indicator between <Link /> navigations #238
I just peek through the code and it seems to do two async ops mainly: Fetch the code; Fetch data. So, we need...
Read more >getInitialProps - Data Fetching - Next.js
For the initial page load, getInitialProps will run on the server only. getInitialProps will then run on the client when navigating to a...
Read more >nextjs getServerSideProps show loading - Stack Overflow
json is being loaded by fetchNextData. I would like to show a loading spinner when I move from one route to another using...
Read more >Refreshing Server-Side Props - Next.js - Josh W Comeau
When the server returns fresh data, the hook will fire, and our loading state will terminate. And it protects us against "incidental" renders, ......
Read more >Data fetching in React and Next.js with useSWR to impress ...
Stale-While-Revalidate is the concept to show stale, cached data, ... For the initial page load, getInitialProps will run on the server only ...
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 FreeTop 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
Top GitHub Comments
I was basically aiming for something else while investigating this: Hiding my loading times.
Currently the flow is like this with a simple fade animation between screens which takes 500ms.
The user sees the page after 1 second.
This is what I was aiming for:
If getInitialProps resolves within 250ms, the user sees the page after 0.5 seconds instead of 1!
With the “withLoading” example I actually just mean exactly that functionality. I added a global loading indicator to the page, a little bar at the top of the page that grows in a known interval. I did not adapt the transitions.