You get scroll restoration automatically with Navi: the router remembers scroll positions as the user moves through the app and restores them on return visits.
How keys work
Section titled “How keys work”Positions are keyed by path plus normalized query. /users?sort=asc and /users?sort=desc remember separate positions, so two sorted views of the same list do not fight over one offset. The cache is capacity-bounded with O(1) eviction, so long sessions do not grow memory without bound.
Opt out
Section titled “Opt out”Two levels of opt-out exist:
| Level | Mechanism |
|---|---|
| Whole navigation | Pass reset_scroll: true on a Link to start the target position from the top. |
| Per navigation call | NavigateOptions.reset_scroll does the same for programmatic navigation. |
Link::new("/dashboard") .reset_scroll(true) .child("Dashboard (from the top)") .build()Mount the component
Section titled “Mount the component”The ScrollRestoration component attaches a scroll-tracking node to your UI. Give it a handle id:
ScrollRestoration::node("main-scroll").build()ScrollRestoration::set_capacity(capacity) bounds how many remembered positions are kept at once.
Next steps
Section titled “Next steps”Runtime & Router OptionsNavigateOptions and the router state behind restoration.
Components referenceThe ScrollRestoration component API.
