Dev Pattern Labs logo
Dev Pattern Labs Blog
Next.js 6 min readOct 18, 2026

Next.js Parallel Routes and Intercepting Routes Explained

Build modals, split views, and soft navigation using Next.js parallel and intercepting routes with @slot patterns and (.) segment conventions.

Dev Pattern Labs Author

Dev Pattern Labs

Peer-reviewed technical tutorial · Production tested

Multiple browser windows showing parallel Next.js route layouts
Executive Summary & Key Insight

Build modals, split views, and soft navigation using Next.js parallel and intercepting routes with @slot patterns and (.) segment conventions. This practical guide covers step-by-step setup, real-world code snippets, security hardening, and common production edge cases.

Introduction

Two of the most powerful — and most misunderstood — features of the Next.js App Router are parallel routes and intercepting routes. Together they let you build complex UI patterns like modals that preserve browser history, split-screen dashboards, and conditional layouts — all within the file-system routing convention.

In this guide you'll learn exactly what both features do, when to use each, and how to build the classic photo gallery with modal pattern.


Prerequisites

  • Next.js 14 or 15 with the App Router
  • Understanding of layout.tsx and page.tsx conventions
  • Familiarity with React Server and Client Components

1. What Are Parallel Routes?

Parallel routes let you render multiple pages simultaneously inside a single layout. Instead of one {children} slot, your layout receives multiple named slots — each resolving to its own page.tsx.

The @slot convention

Create a folder prefixed with @ to define a named slot:

app/
  layout.tsx          ← receives @feed and @modal slots
  page.tsx            ← renders at /
  @feed/
    page.tsx          ← default feed content
  @modal/
    default.tsx       ← rendered when no modal is active (null/empty)
    page.tsx          ← optional — rarely used at root

Your layout accepts the slots as props:

// app/layout.tsx
export default function RootLayout({
  children,
  feed,
  modal,
}: {
  children: React.ReactNode;
  feed: React.ReactNode;
  modal: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        {children}
        {feed}
        {modal}
      </body>
    </html>
  );
}

The default.tsx fallback

When a slot has no matching page for the current URL, Next.js renders default.tsx instead. Without it, you get a 404 for that slot.

// app/@modal/default.tsx
export default function ModalDefault() {
  return null; // render nothing when no modal is open
}

2. Parallel Route Use Cases

Dashboard with independent panels

app/
  dashboard/
    layout.tsx        ← has @analytics and @activity slots
    page.tsx
    @analytics/
      page.tsx        ← /dashboard — analytics panel
    @activity/
      page.tsx        ← /dashboard — activity panel
      default.tsx

Both panels load independently — if @analytics is slow, it doesn't block @activity from rendering.

Conditional rendering based on auth

// app/layout.tsx
import { getServerSession } from 'next-auth';

export default async function Layout({
  children,
  dashboard,
  login,
}: {
  children: React.ReactNode;
  dashboard: React.ReactNode;
  login: React.ReactNode;
}) {
  const session = await getServerSession();
  return <>{session ? dashboard : login}</>;
}

3. What Are Intercepting Routes?

Intercepting routes let you render a route within the current layout context when navigating client-side — while showing the full page on hard navigation (direct URL, refresh).

The classic example: a photo feed where clicking a photo opens it in a modal (soft nav), but opening the photo URL directly shows the full photo page (hard nav).

The (.) prefixes

PrefixIntercepts from
(.)segmentSame level
(..)segmentOne level up
(..)(..)segmentTwo levels up
(...)segmentRoot

File structure

app/
  layout.tsx
  page.tsx                     ← photo feed
  @modal/
    default.tsx                ← null (no modal)
    (.)photos/
      [id]/
        page.tsx               ← modal version
  photos/
    [id]/
      page.tsx                 ← full photo page (hard nav)

Step 1 — The root layout with the modal slot

// app/layout.tsx
export default function Layout({
  children,
  modal,
}: {
  children: React.ReactNode;
  modal: React.ReactNode;
}) {
  return (
    <html lang="en">
      <body>
        {modal}
        {children}
      </body>
    </html>
  );
}

Step 2 — The feed page

// app/page.tsx
import Link from 'next/link';

const photos = [
  { id: '1', src: 'https://picsum.photos/id/1/600/400', title: 'Forest' },
  { id: '2', src: 'https://picsum.photos/id/2/600/400', title: 'Laptop' },
  { id: '3', src: 'https://picsum.photos/id/3/600/400', title: 'Coffee' },
];

export default function FeedPage() {
  return (
    <div style={{ display: 'grid', gridTemplateColumns: 'repeat(3, 1fr)', gap: 16, padding: 24 }}>
      {photos.map((photo) => (
        <Link key={photo.id} href={`/photos/${photo.id}`}>
          <img src={photo.src} alt={photo.title} style={{ width: '100%', borderRadius: 8 }} />
        </Link>
      ))}
    </div>
  );
}

Step 3 — The intercepting modal version

// app/@modal/(.)photos/[id]/page.tsx
'use client';
import { useRouter } from 'next/navigation';

export default function PhotoModal({ params }: { params: { id: string } }) {
  const router = useRouter();

  return (
    <div
      onClick={() => router.back()}
      style={{
        position: 'fixed', inset: 0,
        background: 'rgba(0,0,0,0.85)',
        display: 'flex', alignItems: 'center', justifyContent: 'center',
        zIndex: 100,
      }}
    >
      <div onClick={(e) => e.stopPropagation()}>
        <img
          src={`https://picsum.photos/id/${params.id}/800/600`}
          alt="Photo"
          style={{ borderRadius: 12, maxWidth: '90vw', maxHeight: '80vh' }}
        />
        <button
          onClick={() => router.back()}
          style={{ position: 'absolute', top: 16, right: 16, color: '#fff', fontSize: 24 }}
        >
          ✕
        </button>
      </div>
    </div>
  );
}

Step 4 — The full photo page (hard navigation)

// app/photos/[id]/page.tsx
export default function PhotoPage({ params }: { params: { id: string } }) {
  return (
    <div style={{ padding: 40 }}>
      <img
        src={`https://picsum.photos/id/${params.id}/1200/800`}
        alt="Full photo"
        style={{ width: '100%', borderRadius: 12 }}
      />
    </div>
  );
}

Step 5 — The modal default (nothing)

// app/@modal/default.tsx
export default function ModalDefault() {
  return null;
}

Result: Clicking a photo from the feed opens it in a modal (client-side). Refreshing or sharing the URL /photos/1 shows the full page — no modal.


5. Soft vs Hard Navigation

Navigation typeWhat renders
Client-side <Link> clickIntercepting route (modal)
Full URL visit / page refreshRegular route (full page)
router.back()Dismisses the intercepting route

This is the magic: intercepting routes don't change the canonical page — they just layer over it during client navigation.


6. Combining Parallel + Intercepting Routes

A common pattern in production apps:

app/
  layout.tsx           ← has @modal slot
  @modal/
    default.tsx        ← null
    (.)items/[id]/
      page.tsx         ← item detail modal
  items/
    page.tsx           ← items list
    [id]/
      page.tsx         ← full item detail page

Your items list links to /items/123. Client-side: modal opens over the list. Hard refresh on /items/123: full detail page shows.


7. Common Mistakes

Missing default.tsx

Without default.tsx in a slot, any navigation where the slot has no matching route throws a 404.

Forgetting 'use client' on the modal

The router.back() call and onClick handlers require a Client Component.

Wrong intercept prefix

If your intercepting route is at app/@modal/(.)photos/[id], the (.) intercepts /photos/[id] at the same level as app/. If your photos route is nested deeper, use (..) accordingly.


Conclusion

Parallel and intercepting routes solve a hard problem in React apps: how to show contextual UI (like modals) that:

  • Preserves the URL
  • Supports browser back/forward
  • Shows a full page on direct access
  • Doesn't require client-side state hacks

The key patterns to remember:

  1. @slot folders create named slots in layouts
  2. default.tsx prevents 404s when a slot has no active page
  3. (.), (..), (...) prefixes control which route gets intercepted
  4. Intercepting routes only activate on client-side navigation — hard refreshes bypass them

These features are particularly powerful when building admin dashboards, social feeds, e-commerce product grids, and any UI where context-preserving overlays improve UX.

Tags:#Next.js#App Router#parallel routes#intercepting routes#modals
Dev Pattern Labs Engineering Team

Written by Dev Pattern LabsCore Engineering

Dev Pattern Labs is an engineering lab and digital consultancy specializing in custom Next.js web applications, WooCommerce REST API integrations, and workflow automation for growing businesses.

Recommended Companion Articles