Parallel and intercepting routes
Named @slots that render several pages in one layout, default.tsx fallbacks, and intercepting routes with (.) and (..) for modals that keep deep-linkable URLs.
Parallel and intercepting routes
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- A folder named `@name` is a slot, not a URL segment: its page is passed to the parent layout as a prop with that name, so one layout can render several independent pages side by side.
- On a client-side navigation each slot keeps its own active state, but after a full reload Next.js cannot recover that state, so every slot needs a `default.tsx` or the unmatched slot returns a 404.
- Intercepting routes, written `(.)`, `(..)`, `(..)(..)` and `(...)`, match segments relative to the route tree and let you show a route inside the current layout when reached by a soft navigation.
- A parallel slot plus an intercepting route gives a modal that has its own URL: link or reload and you get the full page, click from the feed and you get the overlay.
When one route per screen is not enough
The usual rule is one URL, one page. Two common UI patterns break it. A dashboard shows an analytics panel and a team panel at once, and each should load and fail independently. A photo feed opens a photo in a modal over the feed, and that modal should have its own shareable URL, but a visitor who arrives at that URL directly should see a full photo page rather than a modal over nothing.
Next.js has two features for these: parallel routes and intercepting routes. They combine for the modal case.
Parallel routes: named slots
Create a folder starting with @ and it becomes a slot:
app/dashboard/
layout.tsx
page.tsx → children slot
@analytics/
page.tsx
default.tsx
@team/
page.tsx
default.tsx
Slots are not URL segments. @analytics does not appear in any path. Each slot’s page is passed to the parent layout as a prop:
// app/dashboard/layout.tsx
export default function Layout({
children,
analytics,
team,
}: LayoutProps<"/dashboard">) {
return (
<div>
{children}
<aside>{analytics}</aside>
<aside>{team}</aside>
</div>
);
}
children is itself an implicit slot, so app/page.tsx is equivalent to app/@children/page.tsx. Because each slot is its own route tree, it can have its own loading.tsx and error.tsx, so one panel can stream in or fail alone. Slots also render on the server whether or not the layout shows them, so if you pick between slots by user role, authorize inside each slot rather than trusting the layout’s conditional to hide data.
default.tsx and the reload problem
Suppose @team has a /settings page and @analytics does not. Go to /settings in the app and Next.js renders the team settings while leaving analytics showing whatever it showed. That is a soft navigation: it tracks each slot’s active state.
Reload the browser on /settings, a hard navigation, and it only has the URL. For analytics it finds no match. If @analytics/default.tsx exists, it renders; if not, you get a 404. That 404 is intentional, so you never render a parallel route on a page it was not meant for. The same applies to the implicit children slot, which needs a default.tsx of its own. The simplest default returns null. Add a default whenever you add a slot.
Intercepting routes
Interception lets you load a route from elsewhere in the app inside the current layout, when the user got there by clicking a link. The folder name encodes how far up to look, like ../ for route segments:
(.)matches a segment at the same level,(..)one level above,(..)(..)two levels above,(...)from the rootappdirectory.
The convention is based on route segments, not the file system, so @slot folders do not count as a level.
The modal pattern
Combine the two for the classic modal. A feed at / links to /photos/7. You provide both a full page and an intercepted version in a @modal slot:
app/
layout.tsx renders {children} and {modal}
page.tsx the feed
photos/[id]/page.tsx the full photo page
@modal/
default.tsx returns null
(.)photos/[id]/page.tsx the modal version
Click a photo from the feed: a soft navigation, so (.)photos/[id] intercepts and the modal renders in the @modal slot over the feed, with the URL showing /photos/7. Paste that URL or refresh: a hard navigation, no interception, so the full photos/[id]/page.tsx renders. Back closes the modal; forward reopens it. All of this comes from the conventions, with no modal state in your code beyond rendering a dialog, and the slot’s default.tsx returns null so nothing shows when no photo is open.
This builds clean on Next.js 16 (I built it with Cache Components on): params reads sit inside <Suspense> for routes with no generateStaticParams, which the scaffold’s strictness requires.
What the video covers
Codevolution’s parallel routes video (chapters: setting up parallel routes, a complex dashboard layout, implementing slots, building and wrapping components, testing and troubleshooting, benefits, independent route handling and sub-navigation) covers slots and unmatched routes; it does not cover interception. Its intercepting routes video and Web Dev Simplified’s intercepting routes video are linked under deeper, and are where the modal pattern is built. They were recorded for Next.js 14 and 15, before params became strictly async, but the file conventions are unchanged.
Where this fits
Parallel and intercepting routes are the most advanced routing tools, so they come last. Next, redirects and rewrites covers changing where a URL goes before a page renders.
Check yourself
Does a folder named `@analytics` add `/analytics` to the URL?
No. Folders starting with `@` are slots, not route segments. `app/@analytics/views/page.tsx` serves `/views`, and the slot's content arrives in the parent layout as the `analytics` prop.
Why do parallel route slots usually need a `default.tsx`?
On a client-side navigation Next.js remembers each slot's active page, but on a full reload it only knows the URL. A slot with no page matching that URL falls back to `default.tsx`, and with no default file you get a 404.
How does an intercepting route avoid breaking shared links to a modal?
It only intercepts on a soft navigation from within the app. A hard navigation, such as pasting the URL or refreshing, does not intercept, so the real page for that URL renders instead of the modal.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.