The Instagram pattern
Click a photo in a feed: a modal opens with the photo. Refresh the page on that URL: you get a full page view of the photo. Same URL, two presentations. Intercepting routes makes this declarative.
The conventions
| Prefix | Means "intercept from" |
|---|---|
(.) | same level segment |
(..) | one level up |
(..)(..) | two levels up |
(...) | app root |
The pattern in code
Use intercepting routes together with parallel routes (@modal) to render the modal version inside the current layout while preserving the deep-link page for refresh/share.
Intercept a route only when the same resource has two legitimate entry contexts: an in-app transition that preserves the current page and a direct URL that must stand alone. The URL should identify the resource in both cases; only the presentation changes. Test closing behavior separately for a full page opened directly and a modal opened over the list. Returning scroll position and focus is part of preserving the same navigation flow.
Not every modal deserves routing. A temporary confirmation with no sharing, refresh, or history meaning is cheaper as local state. Interception earns its complexity when back, forward, direct entry, and new-tab behavior are part of the product contract. Open the resource from the feed, paste its URL into a new tab, refresh the modal URL, and use browser back and forward. Also verify focus enters the dialog and returns to the triggering item. Correct pixels with broken history or focus are not a pass.