Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable missing suspense bailout by default #60840

Merged
merged 4 commits into from Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions errors/missing-suspense-with-csr-bailout.mdx
Expand Up @@ -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)
5 changes: 3 additions & 2 deletions packages/next/src/server/config-shared.ts
Expand Up @@ -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
}
Expand Down Expand Up @@ -866,7 +867,7 @@ export const defaultConfig: NextConfig = {
? true
: false,
webpackBuildWorker: undefined,
missingSuspenseWithCSRBailout: false,
missingSuspenseWithCSRBailout: true,
},
}

Expand Down
@@ -1,8 +1,4 @@
/** @type {import("next").NextConfig} */
const config = {
experimental: {
missingSuspenseWithCSRBailout: true,
},
}
const config = {}

module.exports = config
@@ -1,5 +1,12 @@
'use client'

import { Suspense } from 'react'
import { ParamsComponent } from '../../../shared/params-component'

export default ParamsComponent
export default function Page() {
return (
<Suspense>
<ParamsComponent />
</Suspense>
)
}
@@ -1,4 +1,3 @@
import React from 'react'
import { useParams, useSearchParams } from 'next/navigation'

export function ParamsComponent() {
Expand Down
@@ -1,7 +1,9 @@
'use client'

import { Suspense } from 'react'
import { useSearchParams } from 'next/navigation'

export default function Page() {
function InnerPage() {
const searchParams = useSearchParams()
return (
<>
Expand All @@ -24,3 +26,11 @@ export default function Page() {
</>
)
}

export default function Page() {
return (
<Suspense>
<InnerPage />
</Suspense>
)
}
@@ -1,7 +1,9 @@
'use client'

import { Suspense } from 'react'
import { useSearchParams } from 'next/navigation'

export default function Page() {
function InnerPage() {
const searchParams = useSearchParams()
return (
<>
Expand Down Expand Up @@ -57,3 +59,11 @@ export default function Page() {
</>
)
}

export default function Page() {
return (
<Suspense>
<InnerPage />
</Suspense>
)
}
@@ -1,7 +1,9 @@
'use client'

import { Suspense } from 'react'
import { useSearchParams } from 'next/navigation'

export default function Page() {
function InnerPage() {
const searchParams = useSearchParams()
return (
<>
Expand All @@ -24,3 +26,11 @@ export default function Page() {
</>
)
}

export default function Page() {
return (
<Suspense>
<InnerPage />
</Suspense>
)
}
@@ -1,7 +1,9 @@
'use client'

import { Suspense } from 'react'
import { useSearchParams } from 'next/navigation'

export default function Page() {
function InnerPage() {
const searchParams = useSearchParams()
return (
<>
Expand Down Expand Up @@ -57,3 +59,11 @@ export default function Page() {
</>
)
}

export default function Page() {
return (
<Suspense>
<InnerPage />
</Suspense>
)
}