Given the following Next.js app router structure using parallel routes, what will be rendered on the page?
app/(dashboard)/page.tsx app/(dashboard)/settings/page.tsx app/(marketing)/page.tsx app/layout.tsx The main route renders thedashboardparallel route and themarketingparallel route simultaneously.
app/layout.tsx export default function RootLayout({ children }) { return ( <html lang="en"> <body> <nav>Navigation Bar</nav> {children} </body> </html> ) } app/(dashboard)/page.tsx export default function DashboardPage() { return <h1>Dashboard Home</h1> } app/(dashboard)/settings/page.tsx export default function SettingsPage() { return <h1>Settings</h1> } app/(marketing)/page.tsx export default function MarketingPage() { return <h1>Marketing Home</h1> } app/page.tsx import { ReactNode } from 'react' export default function Page({ dashboard, marketing, }: { dashboard: ReactNode marketing: ReactNode }) { return ( <> <section> {/* Render dashboard parallel route */} {dashboard} </section> <section> {/* Render marketing parallel route */} {marketing} </section> </> ) }
Remember that parallel routes render multiple segments at the same time inside the layout.
The root layout renders the navigation bar and the children. The main page renders both the dashboard and marketing parallel routes inside separate sections. So both Dashboard Home and Marketing Home headings appear.
Which of the following code snippets correctly defines a parallel route segment named admin inside the app directory?
Parallel routes use parentheses around the folder name.
In Next.js app router, parallel routes are defined by wrapping the folder name in parentheses, e.g., (admin). This tells Next.js to treat it as a parallel route segment.
Given this folder structure and code, why does the settings parallel route not appear on the page?
app/layout.tsx app/(dashboard)/page.tsx app/(dashboard)/settings/page.tsx app/page.tsx
Code in app/page.tsx:
export default function Page() {
return (
<>
>
)
}app/(dashboard)/page.tsx export default function DashboardPage() { return <h1>Dashboard Home</h1> } app/(dashboard)/settings/page.tsx export default function SettingsPage() { return <h1>Settings</h1> } app/page.tsx import DashboardPage from './(dashboard)/page' export default function Page() { return ( <> <DashboardPage /> </> ) }
Think about how nested parallel routes render their children.
The settings parallel route is nested inside (dashboard) but the DashboardPage component does not render it. Nested parallel routes must be explicitly rendered in the parent route component to appear.
Consider a Next.js component that toggles between showing two parallel routes using state. What will be the rendered output after clicking the toggle button once?
import { useState } from 'react' export default function ParallelToggle() { const [showMarketing, setShowMarketing] = useState(true) return ( <> <button onClick={() => setShowMarketing(!showMarketing)} aria-label="Toggle routes"> Toggle </button> <section> {showMarketing ? <MarketingPage /> : <DashboardPage />} </section> </> ) } function MarketingPage() { return <h1>Marketing Home</h1> } function DashboardPage() { return <h1>Dashboard Home</h1> }
Initial state is true, what happens after one toggle?
The initial state showMarketing is true, so MarketingPage shows. After clicking toggle once, state becomes false, so DashboardPage renders.
Which of the following best explains how parallel routes enhance user experience in Next.js applications?
Think about how showing multiple UI parts at once affects speed and state.
Parallel routes let Next.js render multiple UI segments side-by-side. This means users can see different parts of the app without waiting for full page reloads, and UI state can be preserved, improving speed and experience.