Unverified Commit 02c2f11e authored by Jiachi Liu's avatar Jiachi Liu Committed by GitHub

Enable missing suspense bailout by default (#60840)

`experimental.missingSuspenseWithCSRBailout` should be enabled by
default to help users to disciver unwrapped suspense boundaries.

Add more notes in the error doc about deprecation and temporary
workaround to disable it.

Closes NEXT-2157

---------
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
parent 2096dfa6
......@@ -10,6 +10,8 @@ Certain methods like `useSearchParams()` opt Next.js into client-side rendering.
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.
> 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.
### Useful Links
- [`useSearchParams`](https://nextjs.org/docs/app/api-reference/functions/use-search-params)
......@@ -387,7 +387,8 @@ export interface ExperimentalConfig {
*
* When this flag is set to `true`, Next.js will break the build instead of warning, to force the developer to add a suspense boundary above the method call.
*
* @default false
* @note This flag will be removed in Next.js 15.
* @default true
*/
missingSuspenseWithCSRBailout?: boolean
}
......@@ -866,7 +867,7 @@ export const defaultConfig: NextConfig = {
? true
: false,
webpackBuildWorker: undefined,
missingSuspenseWithCSRBailout: false,
missingSuspenseWithCSRBailout: true,
},
}
......
/** @type {import("next").NextConfig} */
const config = {
experimental: {
missingSuspenseWithCSRBailout: true,
},
}
const config = {}
module.exports = config
'use client'
import { Suspense } from 'react'
import { ParamsComponent } from '../../../shared/params-component'
export default ParamsComponent
export default function Page() {
return (
<Suspense>
<ParamsComponent />
</Suspense>
)
}
import React from 'react'
import { useParams, useSearchParams } from 'next/navigation'
export function ParamsComponent() {
......
'use client'
import { Suspense } from 'react'
import { useSearchParams } from 'next/navigation'
export default function Page() {
function InnerPage() {
const searchParams = useSearchParams()
return (
<>
......@@ -24,3 +26,11 @@ export default function Page() {
</>
)
}
export default function Page() {
return (
<Suspense>
<InnerPage />
</Suspense>
)
}
'use client'
import { Suspense } from 'react'
import { useSearchParams } from 'next/navigation'
export default function Page() {
function InnerPage() {
const searchParams = useSearchParams()
return (
<>
......@@ -57,3 +59,11 @@ export default function Page() {
</>
)
}
export default function Page() {
return (
<Suspense>
<InnerPage />
</Suspense>
)
}
'use client'
import { Suspense } from 'react'
import { useSearchParams } from 'next/navigation'
export default function Page() {
function InnerPage() {
const searchParams = useSearchParams()
return (
<>
......@@ -24,3 +26,11 @@ export default function Page() {
</>
)
}
export default function Page() {
return (
<Suspense>
<InnerPage />
</Suspense>
)
}
'use client'
import { Suspense } from 'react'
import { useSearchParams } from 'next/navigation'
export default function Page() {
function InnerPage() {
const searchParams = useSearchParams()
return (
<>
......@@ -57,3 +59,11 @@ export default function Page() {
</>
)
}
export default function Page() {
return (
<Suspense>
<InnerPage />
</Suspense>
)
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment