What if you could change the URL without making your users wait for a full page reload?
Why Shallow routing concept in NextJS? - Purpose & Use Cases
Imagine you have a website where users can filter products by category. Every time they click a filter, the whole page reloads, making them wait and losing their scroll position.
Reloading the entire page for small changes is slow and frustrating. It also resets the page state, like scroll position or form inputs, causing a poor user experience.
Shallow routing lets you change the URL and update parts of the page without a full reload. This keeps the page state intact and makes navigation feel instant and smooth.
router.push('/products?category=shoes') // full reloadrouter.push('/products?category=shoes', undefined, { shallow: true }) // no reloadIt enables fast, seamless navigation that feels like a single-page app while keeping URLs in sync.
On an online store, users can switch filters or sort options quickly without losing their place or waiting for the page to reload.
Manual full page reloads cause delays and lose page state.
Shallow routing updates the URL without reloading the page.
This creates a smoother, faster user experience with preserved state.