Recall & Review
beginner
What is shallow routing in Next.js?
Shallow routing lets you change the URL without running data fetching methods again or fully reloading the page. It updates the URL and state smoothly.
Click to reveal answer
beginner
How do you enable shallow routing when using Next.js router?
You pass { shallow: true } as an option to router.push() or router.replace() to enable shallow routing.
Click to reveal answer
intermediate
Why use shallow routing in a Next.js app?
It improves user experience by avoiding full page reloads and skipping data fetching, making navigation faster and smoother.
Click to reveal answer
intermediate
Does shallow routing trigger getServerSideProps or getStaticProps again?
No, shallow routing does not trigger getServerSideProps or getStaticProps again. It only changes the URL and state on the client side.
Click to reveal answer
beginner
Give an example of shallow routing usage in Next.js.
Example: router.push('/page?tab=2', undefined, { shallow: true }) changes the URL query without reloading the page or fetching data again.
Click to reveal answer
What does shallow routing in Next.js avoid?
✗ Incorrect
Shallow routing avoids full page reloads and data fetching, but still changes the URL and updates the browser history.
How do you enable shallow routing when navigating programmatically?
✗ Incorrect
You enable shallow routing by passing { shallow: true } as the third argument to router.push or router.replace.
Which data fetching methods are NOT called again during shallow routing?
✗ Incorrect
Shallow routing does not trigger getServerSideProps or getStaticProps again, so data fetching on the server is skipped.
When is shallow routing most useful?
✗ Incorrect
Shallow routing is useful for updating URL parts like query parameters without reloading the whole page.
What happens to the browser history during shallow routing?
✗ Incorrect
Shallow routing updates the browser history with the new URL, so users can navigate back and forth.
Explain shallow routing in Next.js and why it improves user experience.
Think about how changing tabs on a page without reloading feels faster.
You got /4 concepts.
Describe how to implement shallow routing when changing query parameters in Next.js.
Look at the router methods and their options.
You got /4 concepts.