question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fallback page is not displayed until getStaticProps is done

See original GitHub issue

Verify canary release

  • I verified that the issue exists in Next.js canary release

Provide environment information

Operating System: Platform: win32 Arch: x64 Version: Windows 10 Pro for Workstations Binaries: Node: 14.18.3 npm: N/A Yarn: N/A pnpm: N/A Relevant packages: next: 12.1.4 react: 17.0.2 react-dom: 17.0.2

What browser are you using? (if relevant)

Chrome - 99.0.4844.84

How are you deploying your application? (if relevant)

Bug is detected on local and on Vercel

Describe the Bug

The fallback page is not displayed while getStaticProps is running.

The fallback page is well displayed if the page is directly accessed without routing involved (aka: open directly the page in a new tab).

Expected Behavior

Fallback page should be displayed instantly even if getStaticProps is running.

To Reproduce

Add page “/isr-src.tsx”

import React from 'react'
import Link from "Next/link";


export async function getStaticProps() {
  return {
    props: {}
  }
}

const Page = function () {
  return <div>
    Vercel test ISR - source page
    <div>
      {
        Array.from(Array(50).keys()).map(i => <Link href={`/isr-target/${i}`} prefetch={false} key={i}>page {i}</Link>)
      }
    </div>

  </div>
}
export default Page

Add page “/isr-target/[slug].tsx”

import { GetStaticPropsContext } from "next";
import { useRouter } from "next/router";
import Link from "next/Link";
import React from "react";

export async function getStaticPaths() {
  return {
    paths: [],
    fallback: true
  }
}

export async function getStaticProps(context: GetStaticPropsContext) {
  await new Promise(r => setTimeout(r, 4000));

  return {
    props: {},
    revalidate: 10
  }
}

const Page = function () {
  const { isFallback } = useRouter()
  return <div>
    Vercel test ISR - target page
    <br />
    {isFallback ? 'Loading' : 'Final page'}
    <br/>
    <Link href={'/isr-src'} prefetch={false}><a>back</a></Link>
  </div>

}
export default Page

To reproduce:

  • start from page “/isr-src”
  • open network tab
  • because I have used a next/link the hover will start the prefetch. Please care to direct click the link you want to test.
  • click one link
  • during the fetching of the page we can clairly see in network, the fallback page is not displayed

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:5
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
carlosfaria94commented, Apr 26, 2022

Hi, the fallback page is only expected to show when visiting the page directly and not during client-transitions with next/link.

IMO it doesn’t make sense. The fallback page should appear on client-transitions with next/link. I think it’s an expected behavior…

6reactions
carlosrsabreucommented, Apr 20, 2022

Hi, the fallback page is only expected to show when visiting the page directly and not during client transitions with next/link.

How do users know that page is loading if the fallback page appears when visiting the page directly? How do they get feedback that the requested page is loading when visited using next/link through other project pages? I’m facing the same problem as described with more details here.

Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to handle fallback page with internationalization for ...
Fallback page is displayed until getStaticProps has finished; Fallback page props are empty; Locale is returned by getStaticProps function. I ...
Read more >
Data Fetching: getStaticProps - Next.js
Fetch data and generate static pages with `getStaticProps`. ... getStaticProps is called before initial render when using fallback: blocking; getStaticProps ...
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 >
Routing in Next.js – How to Set Up Dynamic Routing with Pre ...
While getStaticProps() on its own seems to already do all the work we need to be done for our pages, we will encounter...
Read more >
Blocking Fallback for getStaticPaths–New Next.js 10 feature
When Vercel released the 9.3 version of their popular Next.js framework, two brand new data fetching methods were introduced: getStaticProps and ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found