Nearby lessons

35 of 43

🔎 ReactJS – useSearchParams Hook

📌 What is useSearchParams?

What is useSearchParams in React Router?

The useSearchParams hook is provided by react-router-dom v6+. It helps you read and modify the query string parameters in the URL.

It works similarly to useState, but instead of storing component state, it stores URL query parameters.

📌 Why use useSearchParams?

  • Allows reading query string values from the URL
  • Lets you update query parameters dynamically
  • Behaves like React state but syncs with URL
  • Useful for search filters, pagination, or sorting

⚙️ Basic Usage of useSearchParams

The hook returns an array with two values:

  1. searchParams → to read query values
  2. setSearchParams → to update query values
Example03
Loading editor…

🧠 Test Your Knowledge

4 Questions
Progress: 0 / 4