In everything you've seen so far, one URL equals one page inside its layouts. There are two situations where that one-to-one mapping falls short. A dashboard usually brings together several areas that load and fail separately. And a quick view should open on top of the list without leaving it, yet have its own address that can be shared.

Parallel routes let a layout show several pages at once; intercepting routes let a navigation show a different version of the destination. Together they solve the classic problem of the modal with a URL. They're also the part of routing with the most subtle rules, so we'll finish by weighing up when they're worth it.

  1. Parallel routes: slots

A slot is a folder whose name starts with an at sign. Its content reaches the layout of the folder that contains it as one more prop, alongside children:

app/board/
├── layout.tsx            receives children, alerts and stats
├── page.tsx              children
├── @alerts/
│   └── page.tsx          alerts
└── @stats/
    └── page.tsx          stats

Three ideas to get your bearings:

  • They aren't part of the URL. The three pages above all respond to /board, at the same time.
  • children is an implicit slot. board/page.tsx is equivalent to board/@children/page.tsx.
  • Each one is a route tree with its own loading.tsx, error.tsx, layouts and subroutes.

1.1. default.tsx and the two ways of arriving

If each slot is a tree, what does it show when the URL doesn't match any of its pages? It depends on how you got there.

Arrival Slot that matches Slot that doesn't match
Client-side navigation (Link, router.push) Changes Keeps what it was showing
Full load (reload, opening the link) Shows its page Shows its default.tsx

During a navigation, the router remembers the state of each slot. On a full load there's nothing to remember, and it needs fallback content: default.tsx. Since version 16 it's required in named slots; if it's missing, the build fails. Normally it returns null, or calls notFound() if you'd rather have a 404. For children it's optional.

The second column of the first row is the source of almost all the surprises. If you navigate from /board to /board/settings and @alerts doesn't have that subroute, the alerts stay on screen; when you reload, they disappear. The same URL with two different looks is a defect, and you have to design to avoid it.

  1. The dashboard overview

/dashboard will show two independent areas: the organizer's upcoming events and the occupancy of their spots. Each one with its own loading state and its own error.

Placing the slots directly in dashboard/ would cause the problem described above: DashboardLayout also wraps /dashboard/events, and the overview areas would remain visible there after navigating. The solution is a route group that limits the slots to the overview page:

app/(dashboard)/dashboard/
├── layout.tsx                    DashboardLayout, unchanged
├── error.tsx
├── (overview)/
│   ├── layout.tsx                OverviewLayout: places the slots
│   ├── page.tsx                  /dashboard (moved here)
│   ├── @upcoming/
│   │   ├── page.tsx
│   │   ├── loading.tsx
│   │   ├── error.tsx
│   │   └── default.tsx
│   └── @occupancy/
│       ├── page.tsx
│       ├── loading.tsx
│       ├── error.tsx
│       └── default.tsx
└── events/                       /dashboard/events, no slots
mkdir -p "app/(dashboard)/dashboard/(overview)/@upcoming" "app/(dashboard)/dashboard/(overview)/@occupancy"
mv "app/(dashboard)/dashboard/page.tsx" "app/(dashboard)/dashboard/(overview)/page.tsx"

When you go from /dashboard to /dashboard/events you leave the (overview) group, and its layout, with the slots, stops being shown. First, the missing data:

// lib/data/dashboard.ts (addition)
export interface Occupancy {
  spots: number
  booked: number
}

export async function getOccupancy(organizerId: string): Promise<Occupancy> {
  await simulateQuery(1200)
  const published = events.filter(
    (event) => event.organizerId === organizerId && event.status === 'published',
  )
  return published.reduce<Occupancy>(
    (sum, event) => ({
      spots: sum.spots + event.capacity,
      booked: sum.booked + event.capacity - event.spotsLeft,
    }),
    { spots: 0, booked: 0 },
  )
}

The delay is longer on purpose, so you can see that the other area doesn't wait. The layout places the three pieces:

// app/(dashboard)/dashboard/(overview)/layout.tsx
export default function OverviewLayout({
  children,
  upcoming,
  occupancy,
}: LayoutProps<'/dashboard'>) {
  return (
    <>
      {children}
      <div className="mt-8 grid gap-6 lg:grid-cols-2">
        <section aria-label="Upcoming events">{upcoming}</section>
        <section aria-label="Occupancy">{occupancy}</section>
      </div>
    </>
  )
}
// app/(dashboard)/dashboard/(overview)/@upcoming/page.tsx
import { listDashboardEvents, PLACEHOLDER_ORGANIZER_ID } from '@/lib/data/dashboard'
import { formatDateTime } from '@/lib/format'

export default async function DashboardUpcoming() {
  const events = await listDashboardEvents(PLACEHOLDER_ORGANIZER_ID)
  const published = events.filter((event) => event.status === 'published')

  return (
    <>
      <h2 className="text-lg font-semibold">Upcoming events</h2>
      <ul className="mt-2">
        {published.slice(0, 3).map((event) => (
          <li key={event.id}>
            {event.title}, {formatDateTime(event.startsAt)}
          </li>
        ))}
      </ul>
    </>
  )
}
// app/(dashboard)/dashboard/(overview)/@occupancy/page.tsx
import { getOccupancy, PLACEHOLDER_ORGANIZER_ID } from '@/lib/data/dashboard'

export default async function DashboardOccupancy() {
  const { spots, booked } = await getOccupancy(PLACEHOLDER_ORGANIZER_ID)

  return (
    <>
      <h2 className="text-lg font-semibold">Occupancy</h2>
      <p className="mt-2">
        {booked} of {spots} spots booked
      </p>
    </>
  )
}

Both pages wait at their top level, and that's correct because each slot has its own loading.tsx. The supporting files are the same in both:

// loading.tsx in each slot
import { ListSkeleton } from '@/components/list-skeleton'

export default function AreaLoading() {
  return <ListSkeleton items={3} />
}
// error.tsx in each slot
'use client'

import type { ErrorInfo } from 'next/error'
import { ErrorNotice } from '@/components/error-notice'

export default function AreaError({ error, retry }: ErrorInfo) {
  return <ErrorNotice error={error} retry={retry} title="We can't load this area" />
}
// default.tsx in each slot
export default function AreaDefault() {
  return null
}

Run npm run typecheck so that LayoutProps<'/dashboard'> includes the slots, and open /dashboard: the upcoming events appear before the occupancy. If you make getOccupancy throw an error, only that area shows the notice.

2.1. Conditional slots and security

Since slots are props, a layout can choose which one to show based on the role. It's convenient and it hides a trap: every slot is rendered on the server, whether you display it or not, and its output travels in the response. Returning isAdmin ? admin : user doesn't stop the @admin queries from running for everyone. Authorization goes inside each page or in the data access layer (08-04).

  1. Intercepting routes

Intercepting means showing, during a client-side navigation, a different page from the one that corresponds to the destination URL, without leaving the current layout. If you arrive at that same URL with a full load, there's no interception and the normal page is shown.

It's declared with a folder that repeats the destination segment, preceded by a marker similar to relative paths:

Marker Intercepts a segment…
(.) At the same level
(..) One level up
(..)(..) Two levels up
(...) From the root of app

Levels are counted in URL segments, not in folders. @ slots and ( ) groups aren't segments and don't count. This is the rule that causes the most mistakes: from events/@modal/, the sibling segment events/[slug] is intercepted with (.), even though on disk it's one level higher.

  1. An event's quick view

We want this behavior in the guide:

Action Result
Clicking an event on /events?category=theater Modal over the list; the URL changes to /events/the-house-across-the-street
Sharing that URL or reloading Full event page
Close, Escape or "back" Returns to the list with its filter
"Forward" Reopens the modal
flowchart TD
    A["Request for /events/jazz-night"] --> B{"How do you arrive?"}
    B -- "Link from /events" --> C["children: keeps the list<br/>modal: (.)[slug]/page.tsx"]
    B -- "Full load" --> D["children: [slug]/page.tsx<br/>modal: default.tsx"]

The first row combines both techniques: an @modal slot to render into and an intercepting route that decides what to render. children keeps the list precisely because of the rule in section 1.1.

app/(public)/events/
├── layout.tsx                    EventsLayout: children and modal
├── page.tsx                      /events
├── _components/
│   ├── event-details.tsx
│   ├── filter-form.tsx
│   └── modal.tsx
├── @modal/
│   ├── default.tsx               null
│   ├── page.tsx                  null
│   └── (.)[slug]/
│       └── page.tsx              Quick view
└── [slug]/
    ├── not-found.tsx
    └── page.tsx                  Full event page

4.1. The layout and the empty slots

// app/(public)/events/layout.tsx
export default function EventsLayout({ children, modal }: LayoutProps<'/events'>) {
  return (
    <>
      {children}
      {modal}
    </>
  )
}

// app/(public)/events/@modal/default.tsx
export default function NoModal() {
  return null
}

// app/(public)/events/@modal/page.tsx
export default function NoModalOnEvents() {
  return null
}

These are three files, grouped here for brevity. The last two look like duplicates, but they cover different cases:

  • default.tsx kicks in on a full load of /events/[slug], where the slot has no matching page.
  • page.tsx makes the slot match /events. Without it, navigating with a Link from /events/jazz-night to /events would leave the modal open, because a slot with no match keeps what it was showing.

The slot has been placed in events/ and not in (public)/. That way, interception only happens when navigating from /events or its subroutes. From the home page or a venue's page, the link opens the full event page, which makes sense: there's no list to keep there.

4.2. The modal

We'll use the native <dialog> element, which with showModal() provides the backdrop, focus trapping and the Escape key.

// app/(public)/events/_components/modal.tsx
'use client'

import { useLayoutEffect, useRef } from 'react'
import { useRouter } from 'next/navigation'

interface Props {
  title: string
  children: React.ReactNode
}

export function Modal({ title, children }: Props) {
  const router = useRouter()
  const dialogRef = useRef<HTMLDialogElement>(null)

  useLayoutEffect(() => {
    const dialog = dialogRef.current
    if (dialog && !dialog.open) dialog.showModal()
    return () => dialog?.close()
  }, [])

  return (
    <dialog
      ref={dialogRef}
      aria-label={title}
      onCancel={(event) => {
        event.preventDefault()
        router.back()
      }}
      className="m-auto w-full max-w-lg rounded-lg p-6 backdrop:bg-black/50"
    >
      <button type="button" onClick={() => router.back()} className="mb-4 underline">
        Close
      </button>
      {children}
    </dialog>
  )
}
  • Closing is navigating. The modal is open because the URL says so, so it's closed with router.back(). When you go back to /events?category=theater, the slot matches its empty page.tsx and the dialog disappears, while the list keeps its filter.
  • onCancel fires on Escape. The native close, which would hide the dialog without changing the URL, is prevented, and the code navigates instead.
  • The cleanup closes the dialog. Remember that, with Cache Components, pages are hidden instead of unmounted. When it's hidden, React cleans up its effects: without that close(), a modal dialog could remain open in a hidden tree. This is the pattern the documentation recommends.
  • The close event isn't used to navigate. It's also emitted when the cleanup closes the dialog, and it would trigger a second "back".
  • children is server content. The modal is a client component, but what it displays is rendered on the server and handed to it ready-made.

4.3. The intercepting page

// app/(public)/events/@modal/(.)[slug]/page.tsx
import { Suspense } from 'react'
import { ListSkeleton } from '@/components/list-skeleton'
import { getEventBySlug } from '@/lib/data/events'
import { formatDateTime } from '@/lib/format'
import { Modal } from '../../_components/modal'

type Props = PageProps<'/events/[slug]'>

export default function EventQuickView({ params }: Props) {
  return (
    <Modal title="Event quick view">
      <Suspense fallback={<ListSkeleton items={3} />}>
        <QuickViewContent params={params} />
      </Suspense>
    </Modal>
  )
}

async function QuickViewContent({ params }: Pick<Props, 'params'>) {
  const { slug } = await params
  const event = await getEventBySlug(slug)
  if (!event) return <p>This event is no longer available.</p>

  return (
    <>
      <h2 className="text-xl font-semibold">{event.title}</h2>
      <p>{formatDateTime(event.startsAt)}</p>
      <p className="mt-2">{event.summary}</p>
      <a href={`/events/${event.slug}`} className="mt-4 inline-block underline">
        View the full event page
      </a>
    </>
  )
}
  • The type is the destination route's, /events/[slug]: the intercepting page responds to that same URL.
  • The <Suspense> is inside the modal. The dialog and its close button are part of the prefetched shell and appear instantly.
  • A missing event shows a message, not a 404: the list underneath is still valid.
  • "View the full event page" is an <a>. This is the case promised in 02-03. A Link to the current URL wouldn't leave the modal; a full load, which isn't intercepted, leads to the event page.

The content is a summary and not the whole event page. If it were identical, EventDetails would be reused in both places.

4.4. Checking it

Build and start with npm run build and npm run start, filter by theater and go through the table at the beginning of this section: open an event, close it, come back with "forward", reload with the modal open and try Escape. Then open the same event from the home page and check that the event page is shown.

Notice one limitation as well: interception kicks in from any page under /events, including an event page. If an event page ever links to other events, they'll open in a modal on top of it. If you don't want that, those links will have to be <a>.

  1. When they're worth it

They're powerful mechanisms with a high comprehension cost: whoever joins the project will see folders that aren't in the URL, pages that return null and results that depend on how you navigated.

Need Proportionate solution
Several areas that load separately A <Suspense> per area, in the same page
Several areas that fail separately An ErrorBoundary per area
Areas with their own subroutes or tabs that are navigated separately Parallel routes
Transient modal (confirmation, notice) Component state
Modal with a shareable URL, with no equivalent page A parameter, such as ?view=filters
Modal whose URL is also a full page Interception with a parallel slot

The dashboard overview could have been built with two components, each with its own <Suspense> and ErrorBoundary, and it would be simpler. Slots start to pay off when the areas grow, are maintained by different teams or have internal routes. In AgendaViva we keep them so you can see the mechanism at work; in a small project, the component-based option is preferable.

The quick view, on the other hand, is the very case interception was designed for: the event page exists on its own, it should be linkable and indexable, and at the same time people want to glance at it without losing the list.

Common Mistakes and Tips

  • Forgetting default.tsx in a slot. The build fails.
  • Putting the slots in a layout that covers more routes than it should. They stay visible when navigating and disappear on reload. Scope them with a group.
  • Counting folders instead of segments when choosing (.) or (..). Neither @modal nor (group) counts.
  • Not giving the slot an empty page for the origin route: the modal doesn't close when you go back with a Link.
  • Closing the modal by changing local state instead of the URL. The two get out of sync.
  • Creating the intercepting page and forgetting the normal one. The shared URL would return a 404.
  • Using conditional slots as access control. They're all rendered.
  • Linking with Link from the modal to its own URL. Use <a> to force a full load.

Exercises

Exercise 1: choosing the marker

Give the name of the intercepting folder in each case: (1) from app/gallery/@modal/, intercept /gallery/[id]; (2) from app/profile/@modal/, intercept /photo/[id]; (3) from app/(public)/@auth/, intercept /sign-in; (4) from app/a/b/c/@modal/, intercept /help.

Solution

  1. (.)[id]: the current segment is gallery and the destination hangs from it.
  2. (..)photo/[id]: you have to go up from /profile to the root, one segment. @modal doesn't count.
  3. (.)sign-in: neither the group nor the slot are segments, so the current level is the root.
  4. (...)help: there are three levels up to the root, and that's what the marker that starts from app is for.

Exercise 2: diagnosing a dashboard

A teammate places @upcoming directly in app/(dashboard)/dashboard/, with page.tsx and default.tsx (which returns null), and renders it in DashboardLayout. They notice that on /dashboard/events the upcoming events sometimes appear and sometimes don't. Explain why and give two solutions.

Solution

If they arrive by navigating from /dashboard, the slot doesn't match /dashboard/events and keeps its last page: the events appear. If they reload or open the URL directly, default.tsx is used: they don't appear.

  • Scope the slot with the (overview) group, as in the lesson. It's the best option if it only belongs to the overview.
  • Make it always match, with an @upcoming/[...rest]/page.tsx that returns null. A catch-all in the slot empties it on any subroute.

Exercise 3: errors in the quick view

If the QuickViewContent query fails, what will the user see? Make the error show up inside the modal, without losing the list.

Solution

The @modal slot has no error.tsx, so the error bubbles up to (public)/error.tsx, which replaces the entire guide. With an error.tsx in the slot the list would be saved, but the notice would appear outside the dialog, because the boundary sits above the page that contains the Modal. To see it inside, the boundary has to be inside:

<Modal title="Event quick view">
  <ErrorBoundary title="We can't load the event">
    <Suspense fallback={<ListSkeleton items={3} />}>
      <QuickViewContent params={params} />
    </Suspense>
  </ErrorBoundary>
</Modal>

The close button is still available and "Try again" requests the content again. The course keeps this version.

Conclusion

An @ slot gives a layout several pages at once, each with its own loading state and its own error; default.tsx is what it shows when there's no match and no memory of the previous one. Interception makes the same URL appear as a modal when you navigate and as a page when you load it. Both rely on the difference between client-side navigation and a full load, which is why it's best to reserve them for when that difference adds something for the user.

This closes the routing module: AgendaViva has a public map you can browse, the dashboard's skeleton and responses for loading, errors and 404s. Along the way you've written 'use client' several times and passed server content to client components, taking it on trust. Module 3 explains why it works. It starts with Server Components: the Default Behavior, where you'll see exactly what happens when a component runs only on the server.

© Copyright 2026. All rights reserved