Skip to content

QuizNot attempted

Where filter state should live

Product filters (category, sort, page): Context or URL search params?
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • URL search params: shareable, survive refresh, work with back/forward, crawlable, and readable by the server page
  • Filters change what data is shown, so they belong in the URL: shareable, survive refresh, work with back/forward, crawlable, and page.tsx can read searchParams on the server to fetch the filtered data.
  • Not Context: lost on refresh and invisible to the server and to links.
  • Not localStorage: not shareable, not server-readable, and causes hydration mismatches.
  • Not a Redux slice: same problems as Context with more boilerplate.
  • Context suits app-wide state that shouldn't be in the URL (cart, auth).