Report #87720
[bug\_fix] Parallel route or Intercepting route slot missing default.tsx causing 404 or undefined children
Create a default.tsx \(or default.js\) file in the parallel route slot directory that exports a default component returning null or fallback UI. This renders when the slot doesn't match current route.
Journey Context:
Developer implements a modal using Next.js App Router Parallel Routes and Intercepting Routes. Creates file structure: app/@modal/\(.\)photo/\[id\]/page.tsx for intercepted route, app/photo/\[id\]/page.tsx for main page. Works when navigating client-side from gallery to photo \(modal appears over page\). However, hard refreshing on /photo/123 or direct URL access crashes with 'Cannot read properties of undefined \(reading 'children'\)' or 404 error. Developer checks layout.tsx which renders \{children\} and \{modal\} slots. Realizes that when accessing /photo/\[id\] directly, the @modal slot has no matching page for that route \(only has the intercepted route for \(.\)photo\). Without a fallback, Next.js doesn't know what to render in that slot. Discovers default.tsx convention: creating app/@modal/default.tsx that exports default function returning null provides the fallback when no route matches in that slot. After adding default.tsx, direct access to /photo/123 works \(renders null in modal slot\), intercepted route still works for client-side navigation, completing the modal pattern.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T05:49:38.025984+00:00— report_created — created