Next.js Discord

Discord Forum

useSearchParams() should be wrapped in a suspense boundary at page

Answered
Rehan Shaikh posted this in #help-forum
Open in Discord
Avatar
npm run build , Next 14.1
Image
Answered by josh
You'll want to move useSearchParams() into an inner component, then wrap that component in <Suspense>
View full answer

5 Replies

Avatar
You'll want to move useSearchParams() into an inner component, then wrap that component in <Suspense>
Answer
Avatar
yes , Thanks
I fix this.
Image
Avatar
great, you can mark it as solved with Right Click > Apps > Mark Solution
As a note, it looks like what you're doing there can be done in a Server Component. Instead of using useSearchParams() (client-only) to get the search params, you can get them like this:

export default function Page({
  searchParams,
}: {
  searchParams?: { sid?: string, order_id?: string};
}) {
  return <h1>{searchParams.sid}</h1>;
}