The short answer
#A Client Component on a prerendered page calls useSearchParams(), and nothing above it is wrapped in Suspense. The search params are not known at build time, so Next.js needs a boundary to show a fallback in their place. Move the hook into a small component and wrap that component in Suspense.
_14// app/search/page.tsx_14import { Suspense } from 'react';_14import { SearchBar } from './search-bar';_14_14export default function Page() {_14 return (_14 <main>_14 <h1>Search</h1>_14 <Suspense fallback={<p>Loading search...</p>}>_14 <SearchBar />_14 </Suspense>_14 </main>_14 );_14}
Why it happens
#During next build, Next.js tries to prerender every route it can into static HTML. A query string such as ?q=shoes only exists when a real request arrives, so a component that reads it cannot be rendered at build time.
Without a Suspense boundary, Next.js has no smaller piece to skip. The only option would be to render the whole page in the browser, which means a blank page until the JavaScript loads. Rather than do that silently, the production build fails with an error such as useSearchParams() should be wrapped in a suspense boundary at page "/search".
With a boundary in place, Next.js prerenders everything outside it and puts the fallback in the HTML. In the browser, the component inside renders with the real search params.
The error often does not show up in next dev, because development renders every request on demand and the hook does not suspend there. That is why it tends to appear for the first time in CI or on deploy.
If your app uses Cache Components (the cacheComponents option in Next.js 16), the rule is stricter: useSearchParams() always needs a Suspense boundary above it, because search params are request-time data.
How to fix it
#Wrap the smallest component that reads the params
Keep the hook in a dedicated Client Component and wrap only that in Suspense, as in the short answer. The rest of the page stays static and fast.
_11// app/search/search-bar.tsx_11'use client';_11_11import { useSearchParams } from 'next/navigation';_11_11export function SearchBar() {_11 const searchParams = useSearchParams();_11 const query = searchParams.get('q') ?? '';_11_11 return <input name="q" defaultValue={query} placeholder="Search" />;_11}
Make the fallback the same size as the real component, so nothing jumps when it swaps in.
Read searchParams on the server instead
If the page needs the query to fetch data anyway, read it in the page itself. The searchParams prop is a Promise, so await it. This makes the route render on each request, and no client hook is needed.
_10// app/search/page.tsx_10export default async function Page({_10 searchParams,_10}: {_10 searchParams: Promise<{ q?: string }>;_10}) {_10 const { q = '' } = await searchParams;_10 const results = await searchProducts(q);_10 return <Results query={q} results={results} />;_10}
You can also pass the searchParams Promise down to a Client Component and unwrap it there with React's use(). That component still needs a Suspense boundary above it.
Make the route dynamic
If the whole page depends on the request, you can opt it out of prerendering. Without Cache Components, export const dynamic = 'force-dynamic' in the page or layout does this. Calling await connection() from next/server in a Server Component has the same effect. You lose the static shell, so prefer the first fix where you can.
Common pitfalls
#- Wrapping the hook call instead of the component.
Suspensemust sit above the component that calls the hook, in a parent. Wrapping JSX inside the same component does nothing. - Putting the boundary in the root layout. It works, but the whole page becomes the fallback. Keep the boundary close to the component.
- Assuming dev and prod behave the same. Run
next buildlocally before you push.next build --debug-prerendergives fuller stack traces to find the component. - Looking for a config flag to turn it off. The old
missingSuspenseWithCSRBailoutoption only existed in Next.js 14. Fix the boundary instead. - Other client hooks.
usePathname()can trigger the same error on dynamic routes, and the same fix applies.
Related reading
#quick question
Was this resource helpful?
by Danny