Client-side filtering
A list is already loaded through props and the browser query string controls local filtering.
Next.js 16+ · Hook
useSearchParams is a Next.js Client Component hook for reading the current URL query string. It returns a read-only URLSearchParams interface and should be used inside Suspense for prerendered routes.
Call this Client Component hook to read the current URL query string. It returns a read-only URLSearchParams-like object, so use methods such as get, has, getAll, keys, values, or entries to inspect values. For rendering that depends on query parameters during prerendering, place the component below Suspense.
const searchParams = useSearchParams()A read-only URLSearchParams interface.
'use client'
import { useSearchParams } from 'next/navigation'
export default function SearchSummary() {
const searchParams = useSearchParams()
const query = searchParams.get('query') ?? 'all'
return <p>Filtering by: {query}</p>
}Reads the current query parameter in a Client Component.
A list is already loaded through props and the browser query string controls local filtering.
The current query value controls which tab, sort order, or view is displayed in an interactive component.
A Client Component needs to display or react to query values after navigation.
useSearchParams is a Client Component hook from next/navigation that reads the current URL query string. It returns a read-only URLSearchParams interface, so it can inspect values but is not an update API.
Follow-up: How would you update a query parameter? Create a new URLSearchParams from searchParams.toString(), change the copy, then navigate with the router or History API.
It cannot be used in a Server Component because the hook is intended for client-side rendering and navigation. A page should instead use its searchParams prop when the server needs query parameters.
Follow-up: When should the page prop be preferred? Use it when query parameters affect server-side data loading, such as database filtering or pagination.
During prerendering, a component using the hook can suspend, so the documentation recommends placing it inside a Suspense boundary. This lets Client Components above the boundary remain prerenderable and be sent in the initial HTML.
Follow-up: What happens after client navigation? The router already has the URL parameters, allowing the hook to resolve synchronously during that navigation.
URLSearchParamsusePathnameuseRoutersearchParamsSuspense