Scroll Restoration & Not-Found Routes
Restore scroll when navigating back and show a friendly 404 for unknown routes; keep UX smooth on mobile.
Why restore & 404?
Goal: Keep navigation natural.
- Scroll restore when going back
- 404 page for unknown routes
- Simple, lib-free demo
Concepts at a glance
- Save scrollTop per route before leaving
- On mount, read previous and scrollTo
- Catch unmatched paths and show a clear not-found screen
All lessons in this course
- Nested Layouts, Loaders (Concept), Prefetching
- Auth Flows & Protected Routes
- Scroll Restoration & Not-Found Routes