Repository navigation
When do apps need a true 404 after streaming starts? #100192
Replies: 6 comments
|
Thanks for clarifying the behavior and for updating the documentation. |
|
A small follow-up: I found this Framer Marketplace URL still appearing in Yandex Search with its original template title and description. It currently returns HTTP 200, displays “Template unavailable,” and includes noindex. |
|
Use case: a CMS catch-all that needs real status codes for unlisted paths A headless-CMS site serves every public page from one optional catch-all route ( We need real HTTP statuses for those first-seen paths: 404 for a miss, and a permanent redirect with a Observed on 16.4.1 (
Since partial prefetching becomes always on in the next major, could a blocking mode for dynamic params (param matching or similar) be made stable and documented before the option is removed, with redirects kept as real 3xx? Happy to share a minimal reproduction. |
|
One case where a true status matters to us: the sign-in redirect of an authenticated area, which is an entry check in a layout, not an existence check in a page. Shape. A self-hosted multi-tenant app. Everything under a What we see on 16.4.2. With // app/[locale]/layout.tsx
import { locale } from 'next/root-params'
export default async function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang={await locale()}>
<body>{children}</body>
</html>
)
}
export function generateStaticParams() {
return [{ locale: 'en' }, { locale: 'fr' }]
}// app/[locale]/(session)/layout.tsx
import { cookies } from 'next/headers'
import { forbidden, redirect, unauthorized } from 'next/navigation'
export const instant = false
export default async function SessionLayout({ children }: { children: React.ReactNode }) {
const s = (await cookies()).get('s')?.value
if (!s) unauthorized() // or redirect('/en/login'): same 200
if (s === 'forbid') forbidden()
return <section>{children}</section>
}// app/[locale]/(session)/dash/page.tsx
export default function Page() {
return <h1>Dash</h1>
}With Why the 200 matters here. It isn't SEO, since the area is What we're doing instead. Following #100191, the Proxy redirects an anonymous visitor of the |
|
We hit this in a multi-tenant LMS (App Router, Why the UI plus
What we do today, and why it's not great
It works, but:
What would help Something that lets a segment declare a status-relevant check that runs before the first byte, sharing the request cache with the render (close to the Related: #89254 (same issue with |
|
A follow-up with a minimal reproduction, since the thread asks what actually happens. Next 16.4.5,
Every Three things that surprised us:
This is why we keep the status decision in |

Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
With Cache Components, Next.js can start streaming a response before request-time work finishes, even when the prerendered shell has no visible UI. This lets the browser discover and preload CSS, fonts, and images early.
If the response has already been sent with a
200status, a later call tonotFound()cannot change it to404. Next.js still renders the not-found UI and addsnoindex.Waiting would preserve the final status code, but it would also delay the response and asset discovery on successful requests. Running an earlier check in Proxy can guarantee the request-time status, though that may require splitting or repeating some data-fetching logic.
We would like to understand the real-world cases where a true
404is important. What does it enable that the not-found UI andnoindexdo not? And what makes an earlier check impractical for your application? Concrete examples would help us understand the tradeoff.Further reading:
All reactions