Skip to main content
Scroll restoration automatically manages scroll position when users navigate between routes, maintaining a smooth browsing experience.

Automatic scroll restoration

TanStack Router automatically scrolls to top on navigation by default:

Scroll restoration options

Configure global scroll behavior:

Per-route scroll behavior

Override scroll behavior for specific routes:

Custom scroll restoration

Implement custom scroll logic:

Scroll to hash

Automatically scroll to hash fragments:

Programmatic scrolling

Control scroll position during navigation:

Preserve scroll on navigation

Keep scroll position when navigating:

Smooth scrolling

Use smooth scroll behavior:
Or control via JavaScript:

Scroll on route update

Scroll when route params change:

Scroll position tracking

Track scroll position for analytics:

Scroll restoration with layouts

Handle scroll in nested layouts:

Skip to content

Implement accessibility skip links:

Infinite scroll

Implement infinite scroll with scroll restoration:

Best practices

Use resetScroll={false} when navigating between pages of content.
Let the browser handle scroll restoration for back/forward navigation.
Scroll behavior can differ significantly on mobile - always test there.

Common patterns

Scroll to top button

Remember scroll position

Next steps

Navigation

Learn navigation patterns

Link component

Explore Link API