Skip to main content
GoodFirstPicks
DashboardIssuesReposLeaderboard

GoodFirstPicks by Leaveitblank © 2026

CreatorRequest a RepoPrivacy PolicyTerms of Service
Swipe back on mobile browser with getInitialProps flickers the previous page | GoodFirstPicks

Swipe back on mobile browser with getInitialProps flickers the previous page

vercel/next.js 24 comments 27d ago
View on GitHub
mediumopenScope: somewhat clearSkill match: maybeNext.jsTypeScriptReact

Why this is a good first issue

The issue involves mobile-specific behavior and timing-sensitive rendering.

AI Summary

The issue describes a flickering effect when swiping back or forward on mobile browsers with dynamic pages using `getInitialProps`. The problem seems timing-sensitive and mobile-specific, requiring a fix that ensures smooth transitions without flashes of previous content.

Issue Description

Bug report

Describe the bug

On mobile browsers (tested with Chrome and Firefox), swiping back or forward on a dynamic page (one that gets data from getInitialProps) will sometimes "flash" the previous page while the content is loading. Here is a video that shows the problem.

To Reproduce

  1. Create a next.js app with the following pages:

index.js

import Link from "next/link";

export default function Index() {
  return (
    <div>
      <p><Link href="data"><a>Link</a></Link></p>
    </div>
  );
}

data.js

const Index = props => {
  return (
    <div>
      <h1>Test mobile back</h1>
      <ul>
        {props.data.map(name => (
          <li key={name}>
              <a>{name}</a>
          </li>
        ))}
      </ul>
    </div>
  )
};

function sleep(ms) {
  return new Promise((resolve) => {
    setTimeout(resolve, ms);
  });
}

Index.getInitialProps = async function() {
  await sleep(1000)

  return {
    data: ["one", "two", "three", "four", "five", "six"]
  };
};

export default Index;
  1. Run it, and access it with a mobile browser.
  2. Click on the link, you are now on a page with "one", "two"...
  3. Swipe back
  4. Now swipe forward. Notice the "flash" of the previous screen.

Now, add "seven" to the data returned in data.js, and notice the problem doesn't happen anymore

Expected behavior

No flash of the previous page when swiping forward or backward on mobile browser. This is what happens now vs this is what should happen

System information

  • OS: MacOS
  • Browser (if applies): Mobile Safari, chrome and firefox
  • Version of Next.js: 9.2.1

GitHub Labels

good first issueLinking and Navigating

Want to work on this?

Claim this issue to let others know you're working on it. You'll earn 20 points when you complete it!

Risk Flags

  • mobile-specific behavior
  • timing-sensitive issue
Loading labels...

Details

Points20 pts
Difficultymedium
Scopesomewhat clear
Skill Matchmaybe
Test Focusedno