javascriptreactjsnext.jsnext.js13next-router

Next JS doesn't navigate correctly on press of mobile back button


I just created a website using Next js 13 (with app router) and Mantine UI (for front end).

On mobile, I'm displaying a responsive menu in the homepage. When I navigate to the dashboard from one of my links in the Modal/Drawer menu, I am unable to return back to the homepage by pressing the back button on mobile.

When I press the back button on mobile, I see the homepage for a moment and almost immediately I'm redirected back to the dashboard. (The url also changes)

However, if I try to navigate using links to the dashboard (without pressing the mobile back button), there is no issue. The 4 cards in the homepage also navigate to the dashboard, but this problem doesn't occur.

This is happening only on mobile devices. Everything works fine on desktop (even in mobile responsive mode). Also works on mobile if you use the desktop version.

Here's the link to the hosted website on Netlify - https://talentelly.netlify.app/

Steps to reproduce-

  1. Access the website from a mobile device. Click on the hamburger icon in the top right corner to open the navigation drawer menu.
  2. Click on the green Sign Up button and you will be redirected to the dashboard.
  3. Now click the mobile back button. You will notice that you are immediately redirected to the dashboard again. (If this doesn't happen immediately, just scroll or perform some activity in the page.)

This is the codebase/file structure for my application-

Codebase File Structure

HeaderMegaMenu component-

Header mega menu code

Any help is appreciated!


Solution

  • I just upgraded the next version to v13.5.3, and this problem finally no longer occurs.