Advertisement
Intermediate Next.js, Parallel Routes & Intercepting Routes

What is an intercepting route, and what problem does it solve?

Short answer

An intercepting route lets you show a different view when a link is clicked from within your app, such as opening a photo in a modal overlay, while still showing the full dedicated page if that same URL is visited directly, such as through a page refresh or a shared link.

Save Next.js mock interview
Advertisement
AModel answer
An intercepting route lets you show a different view when a link is clicked from within your app, such as opening a photo in a modal overlay, while still showing the full dedicated page if that same URL is visited directly, such as through a page refresh or a shared link.
Example

// app/feed/@modal/(.)photo/[id]/page.js // This intercepts navigation to /photo/[id] from within /feed // showing it in a modal instead of a full page navigation

Real-world example
A photo sharing app shows a photo in a modal overlay when a user clicks it from their feed, while directly visiting or sharing that same photo's link still loads the complete standalone photo page.
Likely follow-ups
  • What do the different dot notation symbols mean in intercepting route folder names?
  • How does this pattern work together with parallel routes for the modal itself?
Related topics