Skip to content
RoutingChapter 9 / 34Advanced5 min read

Parallel & Intercepting Routes

Next.js parallel intercepting routes: show several pages in one layout with @slot, build modal routes with (.), and add the required default.tsx in Next.js 16.

On this page

1. What are parallel and intercepting routes?

Both are advanced routing patterns and they are often used together. The most famous example is an Instagram-style gallery where clicking a photo opens a modal, but the URL changes, and a refresh loads the full photo page.

2. Why does it matter?

Normal routingParallel + intercepting
One page in one layoutSeveral independent slots in one layout
A modal has no URLA modal has its own shareable URL
A refresh makes the modal disappearA refresh opens the full page
Dashboard sections share one loading stateEach slot has its own loading and error

3. Where is it used?

Use casePattern
Analytics and team panels on a dashboard@analytics, @team parallel slots
Photo gallery modal@modal + (.)photo/[id]
Login modal opened from the header@auth + (.)login
A different panel for each roleChoose the slot with a condition in the layout
Cart drawer with a shareable URLIntercepted /cart route

4. How does it work?

Parallel routes

A @name folder is a slot. A slot does not become part of the URL. Instead, the parent layout receives a prop with that name.

Slots reach the layout
app/dashboard/@analytics/page.tsx
app/dashboard/@team/page.tsx
app/dashboard/page.tsx (children)
app/dashboard/layout.tsx receives analytics, team and children props
All three render together

In Next.js 16, every slot needs a default.tsx. On a hard navigation (refresh), when Next.js does not know the current state of a slot, it shows default.tsx. Without it, the build fails.

Intercepting routes

ConventionMeaning
(.)folderIntercepts a segment at the same level
(..)folderA segment one level up
(..)(..)folderTwo levels up
(...)folderFrom the app root

These levels are based on route segments, not on the file system. A slot like @modal does not count as a level.

Photo modal flow
Click a photo link in the gallery (soft navigation)
@modal/(.)photo/[id] intercepts it
Modal appears over the gallery, URL is /photo/7
Refresh or direct link
The real app/photo/[id]/page.tsx opens as a full page

5. Code example

Folder structure

bash
app/
  layout.tsx
  page.tsx
  @modal/
    default.tsx
    (.)photo/[id]/page.tsx
  photo/[id]/page.tsx

Slot in the root layout

tsx
export default function RootLayout({ children, modal }: LayoutProps<"/">) {
  return (
    <html lang="en">
      <body>
        {children}
        {modal}
      </body>
    </html>
  );
}

default.tsx and the modal page

tsx
export default function Default() {
  return null;
}
tsx
import { Modal } from "@/components/modal";

export default async function PhotoModal({
  params,
}: {
  params: Promise<{ id: string }>;
}) {
  const { id } = await params;
  return (
    <Modal>
      <img src={`/photos/${id}.jpg`} alt={`Photo ${id}`} />
    </Modal>
  );
}
tsx
"use client";

import { useRouter } from "next/navigation";

export function Modal({ children }: { children: React.ReactNode }) {
  const router = useRouter();
  return (
    <div className="fixed inset-0 bg-black/60" onClick={() => router.back()}>
      <div onClick={(e) => e.stopPropagation()}>{children}</div>
    </div>
  );
}

How does the code work?

PartMeaning
@modalA slot, the layout receives a modal prop
LayoutProps<"/">A type helper that also types the slot props
@modal/default.tsxRenders null when the modal is not active
(.)photo/[id]Intercepts /photo/[id] at the same level
router.back()Closes the modal and restores the previous URL
app/photo/[id]/page.tsxThe full page on refresh or direct visit

Interview tip

"Why should a modal have a URL?" So the user can share the link, does not lose the content on refresh, and the back button closes the modal. Parallel and intercepting routes give you exactly that.

6. Common mistakes

Mistake: Not creating default.tsx for a slot

Why? In Next.js 16, the build fails without a default file.

Better: Add a default.tsx to every slot that returns null or calls notFound().

Mistake: Counting intercept levels from the file system

Why? Levels are counted by route segments, and an @slot folder is not a level.

Better: Inside @modal, use (.) for the same URL level and do not count the slot.

Mistake: Using router.push to close the modal

Why? It adds an extra history entry, and the modal opens again when the user presses back.

Better: Use router.back() to close the modal.

7. What to learn before and after

Final quick revision

PointDetail
Parallel slot@name folder, passed to the layout as a prop
Effect on the URLA slot does not appear in the URL
default.tsxRequired for every slot in Next.js 16
Intercept(.), (..), (...)
Soft navigationShows the intercepted UI (modal)
RefreshShows the real full page