← All fixes
Next.js build: useSearchParams() should be wrapped in a suspense boundary
#114Error
useSearchParams() should be wrapped in a suspense boundary at page "/search". Read more: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout
Why it happens, and why this works
During next build the page is pre-rendered without a URL, so a client component that reads search params can't render there. Next requires a Suspense boundary so the rest of the page can still be static.
Fix
Wrap the component that calls useSearchParams in <Suspense> in its parent: <Suspense fallback={null}><SearchBar /></Suspense>. Or read searchParams as a prop in the page (server side) and pass values down; that makes the page dynamic.Did it work?
No reports yet0 worked0 didn't
Tried it yourself?
Related fixes
next build fails prerendering a page that queries the database
#4Error occurred prerendering page "/leaderboard". Error: DATABASE_URL is not set. Export encountered an error, exiting the build.
TypeError: Cannot read properties of undefined (reading 'map')
#61TypeError: Cannot read properties of undefined (reading 'map')
nodejavascriptreactVerifiedNo reports yet
TS6133: 'x' is declared but its value is never read (build fails on an unused import)
#92error TS6133: 'b' is declared but its value is never read.
typescriptviteVerifiedNo reports yet