Next.js Discord

Discord Forum

Error when build: ⨯ useSearchParams() should be wrapped in a suspense boundary at page

Unanswered
Spectacled bear posted this in #help-forum
Open in Discord
Avatar
Spectacled bearOP
Hello,

I'm working on a project that use refine and Next.js 14.2.11, all is fine in dev mode but when I'm trying to build the project I got the error in related attachments (error-reported.png).

I just disable missingSuspenseWithCSRBailout flag in next.config.js but I want to understand what is happening. Attached my page and part of component, any sugestion or help I will be so many gratefully.
Image
Image
Image

9 Replies

Avatar
To solve this issue wrap your component that needs the useSearchParams inside a suspense boundary. Like that the error will be gone
Avatar
Eastern yellowjacket
you need to add a loading.tsx file
Avatar
thanks for your confirmation
Avatar
@Spectacled bear solved?
Avatar
Spectacled bearOP
@B33fb0n3 nope, that is strange :/ I'm taking a deep learn to understand what is happening, maybe refine needs a PR with the solution
Avatar
Spectacled bearOP
@B33fb0n3 yes!
Avatar
remove the logic from your Page function
have a rsc wrapper that wrapps the async component with a suspense