# Intercepting Routes (..)

> Context-aware routing for modals and overlays.

Subject: Next.js | Lesson 19 of 65 | 6 min read
Interactive lesson: https://codewithanimation.in/nextjs/intercepting-routes
Previous: [Parallel Routes (@slot)](https://codewithanimation.in/nextjs/parallel-routes.md) | Next: [<Link> Component](https://codewithanimation.in/nextjs/link-component.md)

## The modal problem

Historically, building modals that update the URL without losing the background page was extremely difficult.

Next.js solves this with Intercepting Routes. Using relative path conventions like `(.)` to match the same level, or `(..)` to match one level up, you can 'intercept' a route request and show a different UI than the standalone page.

## Soft vs Hard Navigation

The magic of Intercepting Routes is that they only trigger during client-side (soft) navigation.

If a user is looking at a feed (`/feed`) and clicks a link to `/photo/1`, Next.js intercepts it and pops open a modal. However, if the user hits refresh, or shares that `/photo/1` URL with a friend, Next.js performs a hard navigation and renders the *standalone* photo page instead.

## The syntax

The syntax mimics relative file paths, but applies to route segments, not physical folders:

`(.)` matches segments on the same level.

`(..)` matches segments one level above.

`(...)` matches segments from the root `app` directory.

## Common mistake: The parallel route pairing

Intercepting routes are rarely used alone. They are almost always paired with Parallel Routes.

If you just intercept a route, it completely replaces the current page. To make it behave like a modal, you must intercept the route *inside* a Parallel Route slot (e.g., `app/@modal/(..)photo/[id]/page.tsx`), so it renders alongside the feed.

## Tip: Closing the modal

To close an intercepted modal, you don't use React state. You navigate backwards.

Calling `router.back()` will close the modal and revert the URL. Alternatively, you can use a catch-all route in your `@modal` slot (`app/@modal/default.tsx`) that returns `null` to clear it out.

## Try it: The Modal Illusion

Click a photo to trigger a soft navigation (intercepting the route for a modal). Then click the 'Simulate Refresh' button to see how a hard navigation bypasses the interceptor entirely.

The animation is on the lesson page and is not part of this text version: https://codewithanimation.in/nextjs/intercepting-routes

## Check yourself

### Question 1

A user opens a photo modal via an Intercepting Route (URL changes to /photo/123). They then hit the refresh button in their browser. What happens?

- A. The modal reloads and stays open over the feed
- B. The full standalone page for /photo/123 loads
- C. They are redirected back to the feed
- D. Next.js throws a 404 error

Correct answer: B

Hard reloads bypass intercepting routes entirely. The server sees a request for `/photo/123` and serves the standard, non-intercepted page components.

- Why not A: Interception only works on soft client-side navigation.
- Why not C: The URL is /photo/123, so the server fulfills that request.
- Why not D: Assuming the standalone page exists, it will load perfectly.

### Question 2

Which folder name syntax intercepts a route at the root 'app' directory level?

- A. (.)
- B. (..)
- C. (...)
- D. (root)

Correct answer: C

The `(...)` convention intercepts a route starting from the root `app` directory, regardless of how deeply nested the interceptor is.

- Why not A: This matches the same level.
- Why not B: This matches one level up.
- Why not D: Not a valid interceptor syntax.

## Remember this

- Intercepting Routes trigger only on soft client-side navigation.
- Hard navigations (refresh, direct link) bypass the interceptor and load the standalone page.
- Syntax uses `(.)`, `(..)`, and `(...)` based on route segment levels.
- They are almost always used inside a Parallel Route (`@modal`) to create overlays.
