Two conventions combine:
- A parallel route slot (
@modal) gives the layout a place to render the modal next tochildren. Itsdefault.jsreturnsnull, so normally there's no modal. - An intercepting route inside the slot, named with a marker plus the target path, such as
(..)photo/[id], tells the router: when a client-side navigation from under this layout goes to/photo/[id], render this page in the slot instead of replacing the page.
So a <Link href="/photo/1"> click in the feed pushes /photo/1 to history, keeps the feed mounted with its state, and shows the intercepted page in @modal. Back pops to /feed and the modal disappears; Forward brings it back. A refresh or a pasted URL is a hard navigation: nothing is intercepted, and the canonical app/photo/[id]/page.js renders as a full page. That's what "survives a refresh": the URL always means "this photo", in a modal or on its own page.
The markers are relative to route segments, not folders: (.) same level, (..) one level up, (..)(..) two up, (...) from the app root. Slots and route groups aren't segments. In app/feed/@modal/(..)photo, the intercepting folder is two folders below feed/ but only one segment, so (..) reaches /photo.
Since 16.4.0, next build rejects an intercepting route with no matching canonical route, which catches a wrong marker.
Interception happens only where the layout holding the slot is rendered. A link to /photo/1 from /other loaded the full photo page, client-side, with no modal.