useSearchParams() should be wrapped in a suspense boundary
The build erroruseSearchParams() should be wrapped in a suspense boundary at page "/search".
Read more: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout
A component reads the URL's search params during a static build. Wrap that component in <Suspense>, or make the page render on each request.
Why it happens
next build tries to pre-render your page into static HTML. Search params like ?q=shoes only exist when a real request arrives. Next.js explains that reading them through useSearchParams() without a Suspense boundary would turn the whole page into client-side rendering, leaving it blank until JavaScript loads, so the build stops.
The dev server renders on every request, so you never see this until you build. That is why it shows up on deploy.
Fix it by hand
- Find the component. The error names the page. If the hook is used deep inside, get a clearer stack trace with:
next build --debug-prerender - Wrap the smallest part that reads search params in Suspense. This keeps the rest of the page static:
'use client' import { useSearchParams } from 'next/navigation' import { Suspense } from 'react' function Search() { const searchParams = useSearchParams() return <input defaultValue={searchParams.get('q') ?? ''} /> } export function Searchbar() { return ( <Suspense fallback={null}> <Search /> </Suspense> ) } - Or render the page on each request. In a Server Component page, call
await connection()fromnext/server. Older code usesexport const dynamic = 'force-dynamic'in a serverpageorlayout; it has no effect in a'use client'file. - Or read params on the server. A Server Component page receives
searchParamsas a prop and can pass it down; unwrap it with React'suse()inside a Suspense boundary. - Don't rely on turning the check off. The
missingSuspenseWithCSRBailoutoption only exists in Next.js 14.x. - Run
next buildagain, then redeploy.
Stop it happening again
- Run
next buildlocally before every push. Most "works in dev, fails on deploy" Next.js errors come from pre-rendering. - Put a rule in your agent's project rules file: any client component using
useSearchParamsgets a Suspense boundary.
Broke After Deploy $9
Broke After Deploy runs your production build with the exact command for your project and catches the type and pre-render errors the dev server hides, then reports them first.
- Checks your project for 37 known causes of "works locally, breaks in production" and runs your production build.
- Paste the error and it finds the cause in your code, then lists what will break next.
- Verdict first. Every finding shows the file and line, what it breaks, and the fix as a diff that is applied only with your OK.
Broke After Deploy: how it works, with examples · Install guide
Works with Claude Code, Claude.ai, Cursor, Codex and other agents that read SKILL.md files. No installs, no accounts, works offline. No-questions refund.