Report #66273
[bug\_fix] useSearchParams only works in Client Components
In a Server Component \(page.tsx\), use the searchParams prop passed to the component: \`export default async function Page\(\{ searchParams \}: \{ searchParams: \{ q?: string \} \}\) \{ ... \}\`. Only use the useSearchParams hook in Client Components \(components with "use client" at the top\).
Journey Context:
Developer is building a search page in Next.js App Router. They create app/search/page.tsx and try to read the query string: \`const searchParams = useSearchParams\(\); const query = searchParams.get\('q'\);\`. The build fails immediately with "useSearchParams only works in Client Components". Developer is confused because they thought page.tsx was just a page. They try adding "use client" to the top, which fixes the hook error, but now they can't export metadata from the page, and the page loses SEO benefits because it's fully client-side rendered. They search the Next.js docs for "useSearchParams" and see the note: "useSearchParams is a Client Component hook". Then they notice the page component signature: \`export default async function Page\(\{ params, searchParams \}\)\`. They realize that in Server Components, searchParams is passed as a prop directly from the framework. They remove "use client", remove the hook, and use \`function Page\(\{ searchParams \}: \{ searchParams: \{ q?: string \} \}\)\` instead. The page now renders server-side with the search results based on the query, and the hook error is gone.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T17:42:50.626080+00:00— report_created — created