Report #95041
[bug\_fix] useSearchParams\(\) should be wrapped in a suspense boundary
Wrap the Client Component that calls useSearchParams\(\) in a React boundary in the parent Server Component to prevent the error during static rendering.
Journey Context:
Developer creates a Client Component \(marked with 'use client'\) that uses useSearchParams\(\) from next/navigation to read URL query parameters. In development \(next dev\), everything works fine. However, when running next build or deploying to Vercel, the build fails with the error: 'useSearchParams\(\) should be wrapped in a suspense boundary'. This happens because Next.js attempts to statically generate pages during the build. useSearchParams requires the browser's location object, which isn't available during static generation or server-side rendering. Without a Suspense boundary, Next.js tries to render the component during the static phase and fails. The fix is to wrap the Client Component in a \}> boundary in the parent Server Component. This tells React to skip rendering that subtree during static generation and wait until the client-side hydration, where useSearchParams works correctly.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T18:06:25.305998+00:00— report_created — created