wrapping useSearchParams into suspense or not?!
Unanswered
Sweat bee posted this in #help-forum
Sweat beeOP
hey, I have a question about the using useSearchParams? The docs say if the pages are rendered statically I have to wrap it into suspense... so far so good. On the SSR Side though it states it does not need to be wrapped.. is this correct? Its not really clear for me...
4 Replies
@Sweat bee hey, I have a question about the using useSearchParams? The docs say if the pages are rendered statically I have to wrap it into suspense... so far so good. On the SSR Side though it states it does not need to be wrapped.. is this correct? Its not really clear for me...
useSearchParams can only be used on the clientside. Even tho the client components are still rendered SSR and only hydrated on the client, it should still be wrapped in a suspense boundary when the docs dont tell anything else. Can you share the docs where it say, that you dont need to add a suspense boundary when having a client components that is SSR rendered?
Sweat beeOP
the docs say: If a route is dynamically rendered, useSearchParams will be available on the server during the initial server render of the Client Component. https://nextjs.org/docs/app/api-reference/functions/use-search-params#dynamic-rendering
here the example doesnt use Suspend... it only uses await connection() to make sure the page is dynamic...
hmm interesting. Yea, then you dont need it there