What if your page could update multiple sections at once, without any messy code?
Why Parallel routes concept in NextJS? - Purpose & Use Cases
Imagine building a website where you want to show a sidebar menu and main content side by side, but each part needs to update independently without reloading the whole page.
Manually managing this means writing complex code to track which parts changed, updating only those, and handling all the loading states yourself. It gets messy and hard to maintain.
Next.js parallel routes let you define multiple routes that render different parts of the page at the same time, so each section updates smoothly and independently without extra hassle.
if (sidebarChanged) { updateSidebar(); } if (contentChanged) { updateContent(); }
export const parallelRoutes = { sidebar: SidebarRoute, content: ContentRoute };This makes building complex layouts with independently updating sections simple, fast, and clean.
Think of an email app where the inbox list updates separately from the email reading pane, so you can keep reading while new emails load in the list.
Manual updates for multiple page parts are complicated and error-prone.
Parallel routes let you split page areas into independent routes that load together.
This leads to smoother user experiences and easier code management.
Practice
Solution
Step 1: Understand what parallel routes do
Parallel routes allow showing multiple UI sections at the same time on a page.Step 2: Compare options with this understanding
Only To display multiple parts of a page simultaneously correctly describes this purpose; others describe unrelated behaviors.Final Answer:
To display multiple parts of a page simultaneously -> Option DQuick Check:
Parallel routes = show multiple parts [OK]
- Thinking parallel routes load pages one after another
- Confusing parallel routes with disabling navigation
- Assuming parallel routes replace client-side routing
Solution
Step 1: Recall folder naming for parallel routes
Next.js uses parentheses around folder names to mark parallel routes.Step 2: Match options to this rule
Only Using parentheses like(route)uses parentheses, which is correct for parallel routes.Final Answer:
Using parentheses like (route) -> Option AQuick Check:
Parallel routes folder = parentheses [OK]
- Using square brackets which are for dynamic routes
- Confusing with curly braces or angle brackets
- Not using any special characters for parallel routes
app/
(sidebar)/
page.jsx
(content)/
page.jsx
layout.jsxWhat will happen when the app renders
layout.jsx with parallel routes?Solution
Step 1: Understand parallel routes folder names
Folders named with parentheses define parallel routes that render simultaneously.Step 2: Apply to given structure
Both (sidebar) and (content) are parallel routes, so their pages render side by side inside layout.Final Answer:
Both sidebar and content pages render side by side inside layout -> Option AQuick Check:
Parallel routes render all named folders simultaneously [OK]
- Thinking only one parallel route renders at a time
- Assuming parallel routes need manual import to render
- Confusing parallel routes with nested routes
layout.jsx to render parallel routes:import { Slot } from 'next/navigation';
export default function Layout() {
return (
<Slot name="sidebar" />
<Slot name="content" />
);
}Why does this code cause an error?
Solution
Step 1: Check JSX syntax in return statement
The code uses <Slot name="sidebar" /> as a string literal, not as JSX tags.Step 2: Correct JSX usage
It should be <Slot name="sidebar" /> without quotes, as a self-closing JSX component.Final Answer:
Because <Slot /> should be self-closing JSX tags, not string literals -> Option BQuick Check:
JSX tags must not be strings [OK]
- Writing JSX tags as strings inside return
- Importing Slot incorrectly
- Thinking Slot can't be used in parallel routes
app/
(sidebar)/
page.jsx
(main)/
page.jsx
layout.jsxAnd in
layout.jsx:export default function Layout() {
return (
{/* What goes here? */}
);
}Solution
Step 1: Match folder names to Slot names
Folders are named (sidebar) and (main), so Slots must use these exact names.Step 2: Check code snippet for correct Slot usage
<Slot name="sidebar" /> <Slot name="main" />uses <Slot name="sidebar" /> and <Slot name="main" />, matching folder names and correct JSX syntax.Final Answer:
<Slot name="sidebar" /> <Slot name="main" /> -> Option CQuick Check:
Slot names = folder names [OK]
- Using wrong Slot names that don't match folders
- Using instead of
- Using only one Slot for multiple parallel routes
Ready to prove it?
Pass the test and this pattern moves unknown
