Reading search params
The query string of a URL — everything after ? — is read through
search params. There are two ways, depending on where you need the value.
In a Server Component page, read them from the searchParams prop. In
Next.js 16 this prop is a Promise, so you await it:
// app/page.tsx
export default async function Page({
searchParams,
}: {
searchParams: Promise<{ [key: string]: string | string[] | undefined }>;
}) {
const filters = (await searchParams).filters;
}
Using searchParams opts the page into dynamic rendering, because Next.js
needs the incoming request to know the query string.
In a Client Component, use the useSearchParams hook, imported from
next/navigation. It is a client hook, so it cannot run in a Server Component.
Reach for the searchParams prop when the query string loads data for the
page (pagination, filtering from a database). Reach for useSearchParams when
the parameters are used only on the client — for example, filtering a list
already loaded through props.
You are about to answer a short quiz on searchParams and useSearchParams.