Request for Support: Next.js Build Failing on Vercel Due to useSearchParams()
Issue Summary
Our Next.js 14+ project fails to build on Vercel due to an error related to useSearchParams() being used inside a server component.
Current Behavior
The deployment fails with the following error:
arduino
CopyEdit
useSearchParams() should be wrapped in a suspense boundary at page "/deckcomercial".
Similar errors occur for /404 and / (home page), causing the build to fail on Vercel.
Expected Behavior
The project should successfully build and deploy without encountering useSearchParams() errors.
Steps to Reproduce
- Using Next.js 14+, deploy a project that includes
useSearchParams()inside a component. - Ensure the component is located within
/app/(which defaults to a server component). - Deploy on Vercel.
- Observe the build failure with the
useSearchParams()error.
What We Have Tried
Adding "use client"; to the component using useSearchParams().
Wrapping the component inside <Suspense>.
Moving useSearchParams() into a separate client-only component.
Ensuring no parent server components depend on the client component.
Despite these changes, the build still fails on Vercel.
Project Information
- Framework: Next.js 14.2.16
- Hosting: Vercel
- Environment: Production
- Affected Routes:
/deckcomercial/404/(home page)
- Relevant Dependencies:
"next": "14.2.16""react": "18.3.1""react-dom": "18.3.1""next/navigation"used foruseSearchParams()
Request for Help
- What is the correct approach to handling
useSearchParams()in a Next.js 14+ app on Vercel? - Is there an official recommendation for structuring components that require
useSearchParams()? - How can we prevent Next.js from trying to prerender pages that rely on
useSearchParams()?
Any guidance, best practices, or insights would be greatly appreciated! ![]()
![]()