Report #42894
[bug\_fix] useSearchParams returns null or throws in Server Component
In Server Components, read \`searchParams\` from the props passed by Next.js \(\`export default function Page\(\{ searchParams \}\)\`\). Only use the \`useSearchParams\(\)\` hook in Client Components \(files with "use client"\). Root cause: The hook accesses the browser's URL API, which is unavailable during server rendering.
Journey Context:
Developer tries to read query parameters in a \`page.js\` file by importing \`useSearchParams\` from \`next/navigation\` and calling it. They receive an error that the hook is only available in Client Components, or it returns \`null\` during SSR. They consider wrapping everything in a Client Component boundary but lose SEO. After consulting docs, they realize that Next.js App Router automatically passes \`searchParams\` as a prop to Server Component pages. For layouts, which don't receive searchParams \(by design\), they must use a Client Component child to access dynamic search params. The fix is destructuring \`searchParams\` from the component props in the page file, avoiding the hook entirely for SSR.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T02:27:51.103516+00:00— report_created — created