Fix fragment link back button issue#8020
Conversation
DipakHalkude
commented
Sep 25, 2025
- Change fragment links from tags to NextLink components in MDX/Link.tsx
- Set history.scrollRestoration = 'auto' for all browsers in _app.tsx
- This prevents multiple new pages in backStack and maintains scroll position
- Similar to how Wikipedia handles fragment links
- Change fragment links from <a> tags to NextLink components in MDX/Link.tsx - Set history.scrollRestoration = 'auto' for all browsers in _app.tsx - This prevents multiple new pages in backStack and maintains scroll position - Similar to how Wikipedia handles fragment links
|
This PR fixes the browser "back" button issue when clicking on fragment links (links that start with # ) in the React documentation. Problem: When users clicked on fragment links like Link and then used the browser's back button, the page would not return to the previous scroll position. Solution:
|
Size changesDetails📦 Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. 🤖 🎉 Global Bundle Size Decreased
DetailsThe global bundle is the javascript bundle that loads alongside every page. It is in its own category because its impact is much higher - an increase to its size means that every page on your website loads slower, and a decrease means every page loads faster. Any third party scripts you have added directly to your app using the If you want further insight into what is behind the changes, give @next/bundle-analyzer a try! Five Pages Changed SizeThe following pages changed size from the code in this PR compared to its base branch:
DetailsOnly the gzipped size is provided here based on an expert tip. First Load is the size of the global bundle plus the bundle for the individual page. If a user were to show up to your website and land on a given page, the first load size represents the amount of javascript that user would need to download. If Any third party scripts you have added directly to your app using the Next to the size is how much the size has increased or decreased compared with the base branch of this PR. If this percentage has increased by 10% or more, there will be a red status indicator applied, indicating that special attention should be given to this. |