Skip to article content
FrontendXLesson 15 / 20

Parallel and Intercepting Routes

A version-qualified path through the Next.js App Router: server components, client boundaries, data fetching, caching layers, streaming, error handling, proxy, images, performance, testing and deployment, with the Next.js 15 and 16 behavior changes called out where they matter.

advanced · about 50 minutes · 6 exercises

  • Predict
  • Explain
  • Implement
  • Debug
  • Test
  • Interview

What you will be able to do

#
  • Compose parallel route slots with independent loading and error states.
  • Build the intercepting modal pattern with soft and hard navigation behavior.
  • Diagnose the default.tsx fallback errors that parallel routes famously produce.

Overview

#

Parallel routes: slots

A folder named @slot defines a named slot that the segment's layout receives as a prop alongside children. Slots render independently, fetch their own data, and have their own loading and error files:

snippet.tsx
// app/dashboard/layout.tsx
export default function Layout({ children, analytics, team }: {
  children: React.ReactNode;
  analytics: React.ReactNode;
  team: React.ReactNode;
}) {
  return (
    <div>
      <main>{children}</main>
      <aside>{analytics}</aside>
      <section>{team}</section>
    </div>
  );
}

The files live at app/dashboard/@analytics/page.tsx and app/dashboard/@team/page.tsx; their URLs are still just /dashboard. Use slots when regions of a page have independent data and loading rhythms, like a live chart next to a slow report.

default.tsx

When the router cannot match a slot for a given URL (typically after a hard navigation to a sub-route that only exists for one slot), the unmatched slot must fall back to something. default.tsx provides that fallback per slot. Version-qualified: Next.js 16 requires an explicit default.tsx for every parallel route slot and fails the build without one; the earlier failure mode was a 404 on reload of a modal route because a sibling slot had no default, and the fix is the same file, rendering the previous content or null.

Intercepting routes: the modal pattern

Convention folders intercept navigation: (.) matches the same level, (..) the parent, (..)(..) two levels up, (...) the root. The canonical use is a photo feed where clicking a photo shows a modal over the feed (soft navigation intercepted), while a direct URL or refresh renders the full photo page (hard navigation):

snippet.txt
app/
  feed/page.tsx
  @modal/default.tsx
  @modal/(.)photos/[id]/page.tsx   # intercepted: modal over the feed
  photos/[id]/page.tsx             # direct load: full page

The modal slot renders the photo detail inside a dialog; the real route renders it as a page. Share the content component between both. The pattern keeps shareable URLs and app-like UX without duplicating rendering logic.

Exercises

#

Reference answers and expected output are authored, not executed in this browser. Nothing you type is run, and there is no Run or Pass control on this page.

  1. Exercise 1Predict

    app/dashboard has @analytics/page.tsx and @team/page.tsx, no default.tsx in either slot. What happens if you run next build on Next.js 16, and what would have happened on Next.js 15 when a user hard-navigated (refresh) to /dashboard/team-view, a sub-route that only exists under @team?

    Choose the best answer
  2. Exercise 2Explain

    Explain the difference between how the photo modal behaves on soft navigation versus hard navigation in the intercepting routes pattern, and why both behaviors are desirable.

    Reveal the reference answer
    reference.text
    Soft navigation (clicking a photo in the feed) is intercepted: the URL becomes /photos/123 but the feed stays mounted underneath and the photo renders in a modal slot, preserving scroll and context. Hard navigation (opening the URL directly, refreshing, or sharing the link) bypasses interception: the real /photos/123 page renders as a full document. Both are desirable because in-app browsing wants continuity while shared or bookmarked URLs must work as standalone pages. The interception convention delivers both from one set of files with a shared content component.

    Authored expected output: Intercepted modal on soft navigation, full page on hard navigation, and the rationale.

    This is the pattern's entire reason to exist.

  3. Exercise 3Implement

    Implement the skeleton of the photo modal pattern: feed page, modal slot with default, intercepted route rendering a Modal wrapper around shared PhotoContent, and the real photo page rendering the same PhotoContent full-width.

    starter.tsx
    // app/feed/page.tsx
    // app/@modal/default.tsx
    // app/@modal/(.)photos/[id]/page.tsx
    // app/photos/[id]/page.tsx

    Reveal the reference answer
    reference.tsx
    // app/feed/page.tsx
    import Link from 'next/link';
    
    export default async function Feed() {
      const photos = await getPhotos();
      return (
        <ul>
          {photos.map((p) => (
            <li key={p.id}><Link href={`/photos/${p.id}`}>{p.title}</Link></li>
          ))}
        </ul>
      );
    }
    
    // app/@modal/default.tsx
    export default function Default() {
      return null;
    }
    
    // app/@modal/(.)photos/[id]/page.tsx
    import { Modal } from '@/components/modal';
    import { PhotoContent } from '@/components/photo-content';
    
    export default async function PhotoModal({ params }: { params: Promise<{ id: string }> }) {
      const { id } = await params;
      const photo = await getPhoto(id);
      return <Modal><PhotoContent photo={photo} /></Modal>;
    }
    
    // app/photos/[id]/page.tsx
    import { PhotoContent } from '@/components/photo-content';
    
    export default async function PhotoPage({ params }: { params: Promise<{ id: string }> }) {
      const { id } = await params;
      const photo = await getPhoto(id);
      return <main className="full-page"><PhotoContent photo={photo} /></main>;
    }

    Authored expected output: In-app clicks show the modal over the feed; direct URLs render the full page.

    PhotoContent is shared so the two surfaces cannot drift.

  4. Exercise 4Debug

    A dashboard's two slots each fetch data, but a failure in the analytics API blanks the whole dashboard. Desired: the team panel keeps working and only the analytics region shows an error. Fix the structure. // app/dashboard/layout.tsx renders {children}, {analytics}, {team} directly

    starter.tsx
    // app/dashboard/layout.tsx
    export default function Layout({ children, analytics, team }) {
      return <div><main>{children}</main><aside>{analytics}</aside><section>{team}</section></div>;
    }

    Reveal the reference answer
    reference.tsx
    Slots already render independently, but without their own error boundaries a thrown error in @analytics propagates to the nearest boundary above the layout. Add app/dashboard/@analytics/error.tsx (client component with reset) so the failure is caught inside the slot region, and optionally @analytics/loading.tsx for its own fallback. The same for @team. Slot-level error and loading files are what make the independence real.

    Authored expected output: An analytics failure shows an error card in the aside while the rest of the dashboard works.

    Independence requires boundaries per slot, not just separate folders.

  5. Exercise 5Test

    Write a pure function interceptConvention(folder: string) mapping convention folders to their match scope: '(.)x' gives 'same-level', '(..)x' gives 'parent', '(..)(..)x' gives 'grandparent', '(...)x' gives 'root', anything else gives 'none'. Assert all four conventions plus a plain folder.

    starter.ts
    export function interceptConvention(folder: string): string {
      // TODO
    }

    Reveal the reference answer
    reference.ts
    export function interceptConvention(folder: string): string {
      if (folder.startsWith('(...)')) return 'root';
      if (folder.startsWith('(..)(..)')) return 'grandparent';
      if (folder.startsWith('(..)')) return 'parent';
      if (folder.startsWith('(.)')) return 'same-level';
      return 'none';
    }
    
    // Order matters: the two-level convention must be checked before the single-level one.

    Authored expected output: All five assertions pass.

    Prefix precedence is the subtle part of the convention table.

  6. Exercise 6Interview

    An interviewer asks: when are parallel routes worth their complexity? Give a justified yes-case, a justified no-case, and the operational cost you warn a team about.

    Reveal the reference answer
    reference.text
    Yes-case: a monitoring dashboard where a live-updating chart slot and a slowly-loading report slot have genuinely different data sources and refresh rhythms; slots give each its own loading and error treatment without coupling their fetches. No-case: a marketing page with a hero and a testimonial row that share one data source and render together; plain composition with children is simpler and the slot machinery buys nothing. Operational cost: every slot must be resolvable for every URL the segment can address, which means default.tsx discipline and slot-level error files, and the failure mode (404 on refresh of a modal route) is confusing enough that teams without the mental model burn a day on it. The decision test is independence: if the regions do not have independent data and failure modes, do not use slots.

    Authored expected output: A yes-case, a no-case, and the default.tsx operational cost.

    Advanced conventions deserve cost-benefit answers, not enthusiasm.

Common misconceptions

#
  • Slots create new URLs. @analytics is rendered inside /dashboard; the folder name never appears in the address bar.
  • default.tsx is optional scaffolding. Without it, unmatched slots after hard navigation produce 404s, the most common parallel-routes bug.
  • Intercepting routes change the URL. The URL is the real route; interception changes what renders during soft navigation only.
  • Modal content must be duplicated for the full page. Extract the shared content component and render it in both the intercepted slot and the real route.

Follow-up practice

#
  • nextjs-routing-and-navigation
  • nextjs-deployment-capstone

Related resources

#

Your progress

#

Answers, drafts and completion marks are stored only in this browser. Nothing is sent to a server and no account is used.

Verification: authored. Answers and outputs on this page are authored reference material, not executed results.

© 2026 FrontendX. All rights reserved.