Next.js · Middle · Question 17 of 75
Why wrap a component using useSearchParams() in <Suspense>?
- ✓Correct answer: Otherwise everything up to the nearest boundary drops out of prerendering
- 2Without Suspense,
useSearchParamsalways returnsnullon the client - 3It's needed only for correct behavior in Safari and iOS
Explanation
Query parameters are unknown during prerendering. If a Suspense boundary sits close to the component, the rest of the page goes into static HTML and only this piece renders on the client. Without a boundary, a large part of the tree becomes client-rendered, and Next.js warns about it.