Intercepting routes lets you show extra content or UI without leaving the current page. It helps keep the user experience smooth and fast.
Intercepting routes (.) in NextJS
app/(group)/page.tsx app/(group)/@modal/page.tsx // Use parentheses for route groups // Use @ prefix for intercepting routes // Link to intercepting route with dot notation: href="/group.(modal)"
Parentheses () create route groups that don't add to the URL path.
The @ prefix marks a folder as an intercepting route.
app/dashboard/page.tsx
app/dashboard/@sidebar/page.tsx
// Link to open sidebar: href="/dashboard.(sidebar)"app/shop/page.tsx
app/shop/@modal/page.tsx
// Link to open modal: href="/shop.(modal)"This example shows a dashboard page with a link that opens a sidebar as an intercepting route. The sidebar content appears next to the main dashboard content without a full page reload.
import Link from 'next/link'; export default function DashboardPage() { return ( <main> <h1>Dashboard</h1> <nav> <Link href="/dashboard.(sidebar)">Open Sidebar</Link> </nav> </main> ); } // In app/dashboard/@sidebar/page.tsx export default function Sidebar() { return ( <aside aria-label="Sidebar"> <h2>Sidebar Content</h2> <p>This content appears alongside the dashboard without leaving it.</p> </aside> ); }
Intercepting routes keep the URL clean and let you show extra UI parts.
Use semantic HTML and ARIA labels for accessibility in intercepting UI like sidebars or modals.
Test in browser DevTools to see how the URL and UI update without full reloads.
Intercepting routes let you add UI parts without leaving the current page.
Use parentheses and @ folders to set up intercepting routes in Next.js App Router.
They improve user experience by avoiding full page reloads and keeping context.
Practice
Solution
Step 1: Understand intercepting routes concept
Intercepting routes allow adding UI parts while staying on the same page, avoiding full reloads.Step 2: Compare options with concept
Options suggesting page reloads, disabling navigation, or forcing server-side rendering contradict the idea of smooth UI updates without full reloads.Final Answer:
To add UI parts without leaving the current page -> Option DQuick Check:
Intercepting routes = add UI parts without leaving page [OK]
- Thinking intercepting routes reload the whole page
- Confusing intercepting routes with disabling navigation
- Assuming intercepting routes force server rendering
Solution
Step 1: Recall folder naming for intercepting routes
Intercepting routes use parentheses around folder names, like (modal), to mark them as intercepting.Step 2: Evaluate options
(modal) uses parentheses correctly. @modal uses @ for parallel routes, modal omits parentheses for regular routes, and [modal] uses square brackets for dynamic routes.Final Answer:
(modal) -> Option CQuick Check:
Intercepting route folder = parentheses [OK]
- Using square brackets instead of parentheses
- Omitting parentheses for intercepting routes
- Confusing @ folders with intercepting route folders
app/(modal)/page.tsxWhat happens when you navigate to a route inside
(modal)?Solution
Step 1: Understand intercepting route behavior
Routes inside (modal) folders add UI parts like modals without leaving the current page.Step 2: Analyze navigation effect
Navigation triggers modal UI overlay, not a full page reload or error.Final Answer:
The modal UI appears without leaving the current page -> Option AQuick Check:
Navigation in (modal) = modal UI without reload [OK]
- Expecting full page reload on modal route
- Thinking navigation causes errors
- Assuming modal opens in new tab
app/@(sidebar)/page.tsx. Why does it cause a build error?Solution
Step 1: Check folder naming rules for intercepting routes
Parentheses indicate intercepting routes; @ folders are separate special folders. Combining them is invalid syntax.Step 2: Identify cause of build error
Using @(sidebar) mixes two folder naming conventions, causing build failure.Final Answer:
Parentheses cannot be combined with @ in folder names -> Option AQuick Check:
Invalid folder name combining ( ) and @ causes error [OK]
- Thinking lowercase folder name fixes error
- Assuming missing layout.tsx causes build error
- Confusing file extension with folder naming
Solution
Step 1: Identify correct intercepting route folder
Using parentheses (sidebar) marks it as an intercepting route folder.Step 2: Confirm layout usage for UI wrapping
Adding layout.tsx inside (sidebar) allows wrapping children with sidebar UI, enabling partial UI updates.Step 3: Evaluate other options
app/sidebar/page.tsx with a layout.tsx inside sidebar wrapping children lacks parentheses, so it's a normal route. app/@sidebar/page.tsx with page.tsx only uses @ which is for special folders, not intercepting routes. app/(sidebar)/page.tsx without layout.tsx misses layout.tsx, so sidebar UI won't wrap children properly.Final Answer:
app/(sidebar)/page.tsx with a layout.tsx inside (sidebar) wrapping children -> Option BQuick Check:
Intercepting route with layout wraps UI correctly [OK]
- Omitting layout.tsx inside intercepting route folder
- Using normal folder instead of (folder) for intercepting route
- Confusing @ folders with intercepting route folders
Ready to prove it?
Pass the test and this pattern moves unknown
