@@ -4,13 +4,52 @@ title: Missing Suspense with CSR Bailout
...
@@ -4,13 +4,52 @@ title: Missing Suspense with CSR Bailout
#### Why This Error Occurred
#### Why This Error Occurred
Certain methods like `useSearchParams()` opt Next.js into client-side rendering. Without a suspense boundary, this will opt the entire page into client-side rendering, which is likely not intended.
Reading search parameters through `useSearchParams()` without a Suspense boundary will opt the entire page into client-side rendering. This could cause your page to be blank until the client-side JavaScript has loaded.
#### Possible Ways to Fix It
#### Possible Ways to Fix It
Make sure that the method is wrapped in a suspense boundary. This way Next.js will only opt the component into client-side rendering up to the suspense boundary.
Ensure that calls to `useSearchParams()` are wrapped in a Suspense boundary.
> Note: There's an option `experimental.missingSuspenseWithCSRBailout` to disable the bailout behavior while you are investigating the missing suspense boundary. But it will be removed in next major version as this is a performance de-opt.
```tsx title="app/page.tsx"
import { SearchBar } from './search'
import { Suspense } from 'react'
export default function Page() {
return (
<Suspense fallback={<div>Loading...</div>}>
<SearchBar />
</Suspense>
)
}
```
```jsx title="app/search.tsx"
'use client'
import { useSearchParams } from 'next/navigation'
export function Search() {
const searchParams = useSearchParams()
return '...'
}
```
This will ensure the page does not de-opt to client-side rendering.
#### Disabling
We don't recommend disabling this rule. However, if you need to, you can disable it by setting the `missingSuspenseWithCSRBailout` option to `false` in your `next.config.js`:
```js filename="next.config.js"
module.exports = {
experimental: {
missingSuspenseWithCSRBailout: false,
},
}
```
This configuration option will be removed in a future major version.