QuizzesNavigation — Link, useRouter and the Router Cache — Concept Check
intermediate
nextjs

Navigation — Link, useRouter and the Router Cache — Concept Check

Questions on Navigation — Link, useRouter and the Router Cache. Link prefetches on hover and swaps only the part of the tree that changed. The surprises come from the client-side cache sitting between you and fresh data.

7 minutes 7 questions Pass at 70%
Time Limit
7 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

7 questions on Navigation — Link, useRouter and the Router Cache — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.A user navigates away from a page and returns within 20 seconds. They see old data instead of updated content. What is likely the cause?

    • AThe router cache retains the previous render for a short period.
    • BThe Link component did not prefetch the data.
    • CThe user's browser cache is outdated.
    • DThe server failed to update the data.
  2. 2.You use `router.replace('/login')` in a Next.js app. What is the result of this action?

    • AAdds a history entry and navigates to '/login'.
    • BClears the router cache and navigates to '/login'.
    • CNavigates to '/login' without adding a history entry.
    • DPrefetches '/login' and navigates to it.
  3. 3.A developer complains that filtering results in their app causes the page to jump to the top. What might be the issue?

    • AThe search parameters are not being updated correctly.
    • BThe router cache is not being cleared after filtering.
    • CThey forgot to set `scroll: false` in `router.replace`.
    • DThey used `router.push` instead of `router.replace`.
  4. 4.What happens when you use `<Link href='/dashboard' replace>` in a Next.js application?

    • ANavigates to '/dashboard' without adding a history entry.
    • BClears the router cache and navigates to '/dashboard'.
    • CPrefetches '/dashboard' and navigates to it.
    • DAdds a history entry and navigates to '/dashboard'.
  5. 5.After saving changes to a problem, a user sees old data when navigating back to the problem list. How can this be resolved?

    • ADisable the router cache entirely.
    • BUse `router.push()` instead of `router.replace()`.
    • CUse `router.refresh()` to re-fetch the current route.
    • DEnsure the server sends fresh data on every request.
  6. 6.Why might a developer use `useSearchParams` in a Next.js component?

    • ATo clear the router cache upon navigation.
    • BTo statically render the component with server-side data.
    • CTo make the component dynamic by reading URL search parameters.
    • DTo prefetch data before the component mounts.
  7. 7.A developer uses `router.push('/problems/two-sum')` in a client component. What is the expected behavior?

    • AClears the router cache and navigates to '/problems/two-sum'.
    • BReplaces the current route with '/problems/two-sum'.
    • CNavigates to '/problems/two-sum' and adds a history entry.
    • DPrefetches '/problems/two-sum' without navigating.