What is the purpose of parallel routes in Next.js using @slot?
Parallel routes let you show different parts of the UI at the same time, like sidebars or modals, without replacing the main page content. The <code>@slot</code> syntax marks where these extra routes appear.
Click to reveal answer
intermediate
How do you define a parallel route in Next.js app router?
You create a folder with the route name inside parentheses, like @sidebar, and inside it, add a page.tsx. Then in the main layout, use {@sidebar} to show it.
Click to reveal answer
beginner
What does the @slot syntax do in Next.js layouts?
It tells Next.js where to render the content of a parallel route. It acts like a placeholder for that route's UI inside the main layout.
Click to reveal answer
intermediate
Can parallel routes update independently without reloading the main page in Next.js?
Yes! Parallel routes let parts of the UI update separately, so you can change a sidebar or modal without reloading the whole page.
Click to reveal answer
intermediate
Why might you use parallel routes instead of nested routes in Next.js?
Parallel routes let you show multiple UI sections side-by-side or overlayed, like a sidebar and main content, without forcing one inside the other. Nested routes replace or nest content, but parallel routes run alongside.
Click to reveal answer
In Next.js, what does the @slot syntax specify?
AThe data fetching method
BWhere to render a parallel route's content
CThe CSS class for styling
DThe URL path of a route
✗ Incorrect
@slot marks the placeholder in a layout where the parallel route's UI will appear.
How do you name a folder to create a parallel route in Next.js app router?
AWith parentheses, like (sidebar)
BWith square brackets, like [sidebar]
CWith curly braces, like {sidebar}
DWith angle brackets, like <sidebar>
✗ Incorrect
Parallel route folders use parentheses to separate them from normal routes.
What happens if you omit @slot in a layout for a parallel route?
AThe route renders twice
BThe app crashes
CThe route becomes the main route
DThe parallel route content won't render in that layout
✗ Incorrect
Without @slot, Next.js doesn't know where to show the parallel route's UI.
Which UI pattern is best suited for parallel routes in Next.js?
ASingle full-page form
BSimple page navigation
CSidebar or modal alongside main content
DStatic content only
✗ Incorrect
Parallel routes let you show multiple UI parts side-by-side or overlayed, like sidebars or modals.
Can parallel routes in Next.js update independently without reloading the whole page?
AYes, they update separately
BNo, they reload the entire page
COnly if using server components
DOnly with client-side routing
✗ Incorrect
Parallel routes allow independent UI updates without full page reloads.
Explain how parallel routes work in Next.js and the role of the @slot syntax.
Think about showing a sidebar and main content together.
You got /3 concepts.
Describe a real-life example where using parallel routes with @slot in Next.js improves user experience.
Imagine a shopping site with filters on the side.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of using @slot in Next.js parallel routes?
easy
A. To display multiple UI parts simultaneously in different route segments
B. To fetch data from an API endpoint
C. To define server-side rendering behavior
D. To create dynamic API routes
Solution
Step 1: Understand the role of @slot
@slot is used to show multiple UI parts at once by matching route segments.
Step 2: Identify the purpose in parallel routes
It allows different UI sections to render in parallel, improving layout flexibility.
Final Answer:
To display multiple UI parts simultaneously in different route segments -> Option A
Quick Check:
Parallel routes use @slot to show multiple UI parts [OK]
Hint: Remember: @slot shows multiple UI parts at once [OK]
Common Mistakes:
Confusing @slot with data fetching
Thinking @slot controls API routes
Assuming @slot is for server rendering only
2. Which of the following is the correct syntax to define a parallel route slot named sidebar in Next.js?
easy
A. export const @slot sidebar = () => <div>Sidebar</div>;
B. export const slot_sidebar = () => <div>Sidebar</div>;
C. export const sidebar = () => <div>Sidebar</div>;
D. export const SidebarSlot = () => <div>Sidebar</div>;
Solution
Step 1: Recall parallel route slot syntax
Slots are exported as named exports matching the slot name, e.g., export const sidebar.
Step 2: Check each option
export const sidebar = () => <div>Sidebar</div>; correctly exports a constant named sidebar as a React component.
Final Answer:
export const sidebar = () => <div>Sidebar</div>; -> Option C
Quick Check:
Slot name matches export const name [OK]
Hint: Export slot as named const matching slot name [OK]
But the sidebar does not appear on the page. What is the likely cause?
medium
A. The slot name sidebar does not match any route segment
B. You forgot to import React
C. The default export must be named sidebar
D. Parallel routes require class components, not functions
Solution
Step 1: Check slot name and route segment matching
Slots render only if their name matches a parallel route segment in the folder structure.
Step 2: Identify mismatch issue
If no route segment named sidebar exists, the slot won't render.
Final Answer:
The slot name sidebar does not match any route segment -> Option A
Quick Check:
Slot name must match route segment [OK]
Hint: Match slot name exactly to route segment folder [OK]
Common Mistakes:
Assuming React import is required in Next.js 13+
Thinking default export must be slot named
Believing only class components work for slots
5. You want to create a layout with parallel routes showing a nav bar and a content area side by side. Which folder structure and code setup correctly implements this using @slot?
hard
A. Folders: app/(nav)/page.tsx and app/(content)/page.tsx with export const nav = () => <nav>Nav</nav>; in nav folder and export default function Page() { return <main>Content</main>; } in content folder
B. Folders: app/(nav)/page.tsx and app/(content)/page.tsx with export default function Nav() { return <nav>Nav</nav>; } and export default function Content() { return <main>Content</main>; }
C. Folders: app/nav/page.tsx and app/content/page.tsx with export default function Nav() { return <nav>Nav</nav>; } and export default function Content() { return <main>Content</main>; }
D. Folders: app/nav/page.tsx and app/content/page.tsx with export const nav = () => <nav>Nav</nav>; in nav folder and export default function Page() { return <main>Content</main>; } in content folder
Solution
Step 1: Understand parallel route folder naming
Parallel routes use folder names without parentheses to define slots, e.g., nav and content.
Step 2: Match slot export and default export
In nav folder, export export const nav for the slot; in content folder, export default the main content.
Step 3: Verify options
Folders: app/nav/page.tsx and app/content/page.tsx with export const nav = () => <nav>Nav</nav>; in nav folder and export default function Page() { return <main>Content</main>; } in content folder correctly uses folders app/nav and app/content with proper exports.
Final Answer:
Folders: app/nav/page.tsx and app/content/page.tsx with export const nav and default export in content -> Option D
Quick Check:
Folder names match slot names without parentheses [OK]
Hint: Use folder names matching slot names without parentheses [OK]
Common Mistakes:
Using parentheses in folder names for slots
Exporting slots as default exports
Mixing slot export and default export roles
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.