Next.js · Middle · Question 17 of 75

Why wrap a component using useSearchParams() in <Suspense>?

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.

Further reading

Problem with a question

Next.js · Middle · question 17

Test yourself

Take the Next.js · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz