Next.js Discord

Discord Forum

'useSearchParams' from 'next/navigation' causing build to fail

Answered
Cão de Castro Laboreiro posted this in #help-forum
Open in Discord
Cão de Castro LaboreiroOP
const searchParams = useSearchParams();

This line here is causing "next build" to fail with this error: Export encountered errors on the following paths:
/searchtest/page: /searchtest

It works normally with "next dev"

Is anyone else experiencing this?

using "next": "^14.1.0"
Answered by Ray
wrap this component with Suspense.
if it is a page component, do this instead
export default function Page({searchParams}) {}
View full answer

3 Replies

Cão de Castro LaboreiroOP
Answer
Cão de Castro LaboreiroOP
Thank you that did it in my case it was a Page component 😄