fallback: true - fallback page could optionally load ASAP when next.js Link is clicked
See original GitHub issueFeature request
Scenario.
- We have a page
/product/[handle]
withfallback: true
. - Let’s say
/product/123
is not yet generated statically. - We have a page
/collection
with next link to/product/123
, no prefetching, or haven’t prefetched yet. - We click on a link.
- Nothing is happening until page is generated and then page reloads. Fallback page wasn’t loaded at any point in time.
Last point could have optional alternative behaviour: showing fallback page ASAP.
Is your feature request related to a problem? Please describe.
We already designed a loading page for when router.isFallback = true
. I want to reuse this loader for next.js reloads when static site is being generated.
Now after clicking next.js link I have either 1-2 seconds moment of “nothing happening” which is bad UX. I cold build a loader on router events, but then I’d have to maintain two loading states instead of one.
Describe the solution you’d like
A flag for Link
? Something like showFallbackImmediately
? Could default to false
to preserve backward compatibility.
Potentially it could be a trait of a page too.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:21
- Comments:8
Top Results From Across the Web
fallback page could optionally load ASAP when next.js Link is ...
We already designed a loading page for when router.isFallback = true . I want to reuse this loader for next.js reloads when static...
Read more >NextJS: Failed when fallback set to true - Stack Overflow
I think fallback blocking is a new feature of nextjs. With blocking, when a request is made to a page that hasn't been...
Read more >Data Fetching: getStaticPaths - Next.js
When a page with fallback: true is navigated to through next/link or next/router (client-side) Next.js will not serve a fallback and instead the...
Read more >Next.js Tutorial - 27 - getStaticPaths fallback true - YouTube
Courses - https://learn.codevolution.dev/⚡️ Checkout Taskade! https://www.taskade.com/ Support UPI - https://support.codevolution.dev/ ...
Read more >How to setup a dev blog using Next.js and next-mdx-remote.
Load mdx content from anywhere through getStaticProps in next.js ... true - fallback page could optionally load ASAP when next.js Link is ...
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 actually thought this was how
fallback: true
already worked, but just implemented it and realized it doesn’t work like that… Did anyone figure out any way to achieve this? I really wanted to eliminate that 1-2 seconds of no-visual-feedback loading time when clicking a Next<Link />
andgetStaticProps
has to build the page…In my case,
router.isFallBack
doesn’t work really well for me. The page still freeze for about few seconds before redirecting to a new route. After several hours of reading docs. I found these 2 events from router:routeChangeStart
androuteChangeComplete
Basically you can listen to when the page has finish redirecting.I’m doing something like this