What is the purpose of intercepting routes in Next.js?
Intercepting routes lets you show parts of a page or UI without leaving the current page. It helps create smooth transitions and nested layouts by loading content inside existing layouts.
Click to reveal answer
beginner
How do you define an intercepting route in Next.js App Router?
You add parentheses around the folder name in the app directory, like (modal), to mark it as an intercepting route. This folder can then load UI inside the current page without full navigation.
Click to reveal answer
intermediate
What is the difference between a normal route and an intercepting route in Next.js?
A normal route replaces the whole page content. An intercepting route loads content inside the current page layout, letting you keep parts of the UI visible while changing others.
Click to reveal answer
intermediate
Can intercepting routes be used to create modals or sidebars in Next.js?
Yes! Intercepting routes are perfect for modals or sidebars because they let you open these UI parts without leaving the current page or losing state.
Click to reveal answer
beginner
What folder naming pattern signals an intercepting route in Next.js App Router?
Folders with parentheses, like (modal) or (sidebar), are intercepting routes. The parentheses tell Next.js to treat them as UI overlays or nested content inside the current page.
Click to reveal answer
How do you mark a folder as an intercepting route in Next.js App Router?
AWrap the folder name in parentheses, e.g., (modal)
BPrefix the folder name with an underscore, e.g., _modal
CAdd a file named intercept.js inside the folder
DUse a special config file in the folder
✗ Incorrect
In Next.js App Router, folders wrapped in parentheses are intercepting routes.
What is a common use case for intercepting routes?
ALoading a full new page
BChanging the URL without changing content
CPreloading images
DShowing a modal without leaving the current page
✗ Incorrect
Intercepting routes let you show modals or sidebars inside the current page.
What happens when you navigate to an intercepting route?
AThe browser opens a new tab
BThe whole page reloads
COnly the content inside the intercepting route updates
DThe URL does not change
✗ Incorrect
Only the part inside the intercepting route updates, keeping the rest of the page intact.
Which folder name is an example of an intercepting route?
A(modal)
Bmodal_intercept
C_modal
Dmodal
✗ Incorrect
Parentheses around the folder name mark it as an intercepting route.
Why use intercepting routes instead of normal routes for UI overlays?
ATo reload the entire page faster
BTo keep the current page visible and only add overlays
CTo disable navigation
DTo hide the URL bar
✗ Incorrect
Intercepting routes keep the current page visible and add overlays like modals or sidebars.
Explain how intercepting routes work in Next.js and why they are useful.
Think about how you open a popup without leaving a webpage.
You got /4 concepts.
Describe the difference between a normal route and an intercepting route in Next.js.
Compare full page reload vs partial UI update.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of intercepting routes in Next.js App Router?
easy
A. To force server-side rendering on every route
B. To reload the entire page on every navigation
C. To disable client-side navigation
D. To add UI parts without leaving the current page
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 D
Quick Check:
Intercepting routes = add UI parts without leaving page [OK]
Hint: Intercepting routes keep you on the page while adding UI [OK]
Common Mistakes:
Thinking intercepting routes reload the whole page
Confusing intercepting routes with disabling navigation
Assuming intercepting routes force server rendering
2. Which folder name syntax is used to create an intercepting route in Next.js App Router?
easy
A. @modal
B. modal
C. (modal)
D. [modal]
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 C
Quick Check:
Intercepting route folder = parentheses [OK]
Hint: Intercepting routes use (folderName) syntax [OK]
Common Mistakes:
Using square brackets instead of parentheses
Omitting parentheses for intercepting routes
Confusing @ folders with intercepting route folders
3. Given this folder structure in Next.js App Router: app/(modal)/page.tsx What happens when you navigate to a route inside (modal)?
medium
A. The modal UI appears without leaving the current page
B. The entire page reloads and shows only the modal content
C. Navigation fails with a 404 error
D. The modal opens in a new browser tab
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 A
Quick Check:
Navigation in (modal) = modal UI without reload [OK]
Hint: Routes in (modal) show UI without page reload [OK]
Common Mistakes:
Expecting full page reload on modal route
Thinking navigation causes errors
Assuming modal opens in new tab
4. You wrote this intercepting route folder: app/@(sidebar)/page.tsx. Why does it cause a build error?
medium
A. Parentheses cannot be combined with @ in folder names
B. The folder name must be all lowercase
C. You need to add a layout.tsx file inside the folder
D. The file extension should be .jsx, not .tsx
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 A
Quick Check:
Invalid folder name combining ( ) and @ causes error [OK]
Hint: Don't mix ( ) and @ in folder names [OK]
Common Mistakes:
Thinking lowercase folder name fixes error
Assuming missing layout.tsx causes build error
Confusing file extension with folder naming
5. You want to show a sidebar UI on some pages without leaving the current page. Which folder structure correctly implements this intercepting route in Next.js App Router?
hard
A. app/(sidebar)/page.tsx without layout.tsx
B. app/(sidebar)/page.tsx with a layout.tsx inside (sidebar) wrapping children
C. app/@sidebar/page.tsx with page.tsx only
D. app/sidebar/page.tsx with a layout.tsx inside sidebar wrapping children
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 B
Quick Check:
Intercepting route with layout wraps UI correctly [OK]
Hint: Use (folder) plus layout.tsx to wrap UI in intercepting routes [OK]