Breadcrumbs Based on @slot Doesn't Trigger 404 Correctly Sometimes
Unanswered
Bigheaded ant posted this in #help-forum
Bigheaded antOP
I implemented breadcrumbs based on [this code](https://github.com/vercel/next-app-router-playground/tree/main/app/patterns/breadcrumbs). However, I noticed that when clicking
Since the breadcrumbs contain custom text, I explicitly invoke the following inside
However, this approach does not work as expected due to the current project structure.
Current Folder Structure:
(Note: This is a dashboard project with an authentication wall.)
Without explicitly calling
Does anyone have suggestions on how to resolve this issue?
Current package version:
<Link href="/some-item/not-found" />
(or certain other links that fail to match any route), no partial rendering occurs at all. In some cases, the layout’s children remain unchanged, and the breadcrumbs are empty. Also the response status is always 200
, regardless of the expected behavior.Since the breadcrumbs contain custom text, I explicitly invoke the following inside
<Breadcrumbs />
:// Ensure at least one breadcrumb contains a valid segment
// Due to a potential bug in Next.js, the 404 page does not render under certain conditions involving breadcrumbs
// Forcefully trigger a 404 page if no breadcrumb segments are found
if (breadcrumbLinks.every((link) => !link)) {
// console.error("No breadcrumb segments found for the given path");
notFound();
}
However, this approach does not work as expected due to the current project structure.
Current Folder Structure:
(Note: This is a dashboard project with an authentication wall.)
app/
- (auth)/
- [some authentication-related pages]
- (protected)/
- @breadcrumbs/
- [...all]/
- page.tsx
- some-item/
- [item]/
- page.tsx # Handles 404 if necessary (SSR)
- page.tsx # (Contains a link to /some-item/not-found)
- layout.tsx # Protected layout
components/
- breadcrumbs.tsx
Without explicitly calling
notFound()
inside the breadcrumbs component, all pages return a 200
status, which seems incorrect. Ideally, it should trigger a 404
, but for some reason, it does not.Does anyone have suggestions on how to resolve this issue?
Current package version:
"next": "^15.1.7"