The page keeps its scroll position after a Next.js Link navigation
Link navigates but the new page opens scrolled downShort answer
Next.js keeps the scroll position on purpose. It only scrolls to the new page when the top of that page is not visible. So a link inside a long page may leave you mid-scroll. Check for scroll={false}, a sticky header, and then add a small scrollTo on route change if you want always-top.
Fix it fast
1Find out which cause you have
Search the code for scroll options that switch scrolling off.
grep -rnE "scroll=\{false\}|scroll: false" app components2Match what you see, then jump to its fix
- 1
Navigation never scrolls, from that one link onlyscroll is set to false on the Link or on router.pushFix - 2
The page scrolls, but content starts hidden under the headerThe first element of the new page is a sticky or fixed headerFix - 3
Works from the top of a page but not from a long page whose first element stays in viewThe new page is already visible, so Next.js leaves the scroll aloneFix
- 1
What does the error look like?
Link navigates but the new page opens scrolled downNew page content hidden behind a sticky header after navigation
Cause 1 of 3
scroll is set to false on the Link or on router.push
1Check
The scroll prop on Link, or scroll: false on router.push and router.replace, tells Next.js not to manage scroll.
grep -rnE "scroll=\{false\}|scroll: false" app components2Fix
Remove it, or set it to true.
<Link href="/dashboard">Dashboard</Link>
router.push('/dashboard') // no scroll option3Verify
Click the link from the middle of a long page.
npm run devConfirmed by nextjs.org
Cause 2 of 3
The first element of the new page is a sticky or fixed header
1Check
The Link docs say Next.js skips sticky and fixed elements when it looks for the scroll target, so content can end up behind a sticky header.
grep -rnE "sticky|fixed" app/layout.tsx app/globals.css2Fix
Offset the scroll with scroll-padding-top equal to the header height.
/* app/globals.css */
html {
scroll-padding-top: 64px; /* header height */
}3Verify
Navigate again; the heading should sit below the header.
npm run devConfirmed by nextjs.org
Cause 3 of 3
The new page is already visible, so Next.js leaves the scroll alone
1Check
By design the default is to maintain the scroll position. Next.js scrolls to the top of the first page element only when that page is not visible in the viewport.
grep -rn "export default function" app/template.tsx app/layout.tsx 2>/dev/null2Fix
If you always want the top, scroll in a small client component placed in the layout and keyed on the pathname.
// app/scroll-top.tsx
'use client'
import { useEffect } from 'react'
import { usePathname } from 'next/navigation'
export function ScrollTop() {
const pathname = usePathname()
useEffect(() => {
window.scrollTo({ top: 0, left: 0, behavior: 'instant' })
}, [pathname])
return null
}3Verify
Click between two long pages; each should open at the top.
npm run devConfirmed by nextjs.org
How do I stop it coming back?
- Treat scroll={false} as an exception, and comment why it is there.
- Set scroll-padding-top as soon as a layout has a sticky header.
- Test navigation from the bottom of a long page, not only from the top.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Web apps
AuthUserPoolException: Auth UserPool not configured in a Next.js app
Auth UserPool not configured
The error means an Amplify Auth call ran before Amplify.configure did.
3 causes, each with a fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
Clerk cannot read its publishable key in a Next.js app
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY is undefined
Clerk reads NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY.
3 causes, each with a fixWeb apps
The shell cannot find create-next-app
command not found: create-next-app
create-next-app is not meant to be installed as a shell command.
2 causes, each with a fixWeb apps
ESLint fails with: Cannot find module 'next/babel'
ESLint stops on the first file with a Babel or parser error instead of listing lint results
next/babel is a Babel preset that ships inside the next package.
3 causes, each with a fixWeb apps
ESLint says an element in a list is missing its key prop
react/jsx-key
react/jsx-key fires when an element returned from map, Array.from or an array literal has no key.
3 causes, each with a fix