Nextjs Fundamentals · App Router

Reading search params

`searchParams` and `useSearchParams`

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.

  1. In Next.js 16, the `searchParams` page prop is a Promise that must be awaited.
  2. A Client Component reads the query string with the ___ hook.
  3. Reading `searchParams` in a page opts it into dynamic rendering.
  4. In a Server Component page, the query string arrives through the ___ prop.
  5. `useSearchParams` is a Client Component hook imported from `next/navigation`.