Next.js Discord

Discord Forum

Entire page deopted into client-side rendering

Answered
Elite posted this in #help-forum
Open in Discord
Avatar
EliteOP
So when i run npm run build to test my build, i get this error
Entire page deopted into client-side rendering
for several of my pages.
I looked at the link and it says that its due to uing useSearchParams with no Suspense Boundary.

I use it in one place (my google analytics component), that is put onto my root layout:
https://gist.github.com/navincodesalot/1b84c87b98481a8938f3987632ad70a1

would i add a suspense wrapped around those scripts here?
Answered by Holland Lop
import { Suspense } from 'react'

export default function Layout() {
const fallback = <div>loading...</div>
return (
#Unknown Channel
// other components
<Suspense fallback={fallback}>
<SearchInput/>
</Suspense>

</>
)
}
View full answer

4 Replies

Avatar
EliteOP
also what does it mean by deopted into csr?
does it mean that the whole page is a client comp, instead of certain parts being server (if its allowed for them)
Avatar
Holland Lop
import { Suspense } from 'react'

export default function Layout() {
const fallback = <div>loading...</div>
return (
#Unknown Channel
// other components
<Suspense fallback={fallback}>
<SearchInput/>
</Suspense>

</>
)
}
Answer
Avatar
Holland Lop
And Yes deopted into csr means that component acts like client component despite 'use server'
Avatar
Clown
Yeah, useSearchParams forces all Client Component upto the nearest Suspense Boundary to be Client Side Rendered. You can counter this by wrapping the Component using useSearchParam with a Suspense.

Check out the example here:
https://nextjs.org/docs/app/api-reference/functions/use-search-params#static-rendering