Challenge - 5 Problems
Nested Routes Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What is rendered by this nested route component?
Consider a Next.js app using the App Router. The folder structure is:
If the user visits
app/dashboard/page.tsxapp/dashboard/settings/page.tsxIf the user visits
/dashboard/settings, what will be rendered?NextJS
app/dashboard/page.tsx export default function Dashboard() { return <h1>Dashboard Home</h1> } app/dashboard/settings/page.tsx export default function Settings() { return <h2>Settings Page</h2> }
Attempts:
2 left
💡 Hint
Think about how Next.js renders page components in nested folders without layouts.
✗ Incorrect
In Next.js App Router, visiting /dashboard/settings renders the page.tsx inside settings folder only. The parent page.tsx is not rendered unless included via layouts.
📝 Syntax
intermediate1:30remaining
Which file name correctly defines a nested route in Next.js App Router?
You want to create a nested route at
/blog/post. Which file path and name is correct?Attempts:
2 left
💡 Hint
Next.js App Router uses folders for routes, not file names with dots.
✗ Incorrect
Nested routes are created by folders. The file app/blog/post/page.tsx defines the /blog/post route.
🔧 Debug
advanced2:00remaining
Why does visiting /profile/settings show a 404 error?
Given this folder structure:
Visiting /profile/settings returns 404. Why?
app/profile/page.tsxapp/profile/settings.tsxVisiting /profile/settings returns 404. Why?
Attempts:
2 left
💡 Hint
Check how nested routes are defined in the App Router.
✗ Incorrect
In Next.js App Router, nested routes must be folders with page.tsx files. A file named settings.tsx inside profile folder does not create /profile/settings route.
❓ state_output
advanced2:30remaining
What is the output when navigating between nested routes with shared layout?
Given this folder structure:
The layout.tsx contains a state hook that increments a counter on button click.
What happens to the counter state when navigating from /dashboard to /dashboard/reports?
app/dashboard/layout.tsxapp/dashboard/page.tsxapp/dashboard/reports/page.tsxThe layout.tsx contains a state hook that increments a counter on button click.
What happens to the counter state when navigating from /dashboard to /dashboard/reports?
NextJS
app/dashboard/layout.tsx 'use client' import { useState } from 'react' export default function DashboardLayout({ children }) { const [count, setCount] = useState(0) return ( <> <button onClick={() => setCount(count + 1)}>Increment {count}</button> <main>{children}</main> </> ) } app/dashboard/page.tsx export default function Dashboard() { return <h1>Dashboard Home</h1> } app/dashboard/reports/page.tsx export default function Reports() { return <h2>Reports Page</h2> }
Attempts:
2 left
💡 Hint
Layouts in Next.js persist state across nested routes.
✗ Incorrect
Layouts wrap nested routes and keep their React state alive when navigating between child pages.
🧠 Conceptual
expert3:00remaining
How does Next.js App Router handle parallel nested routes with folders?
You want to render two different nested routes side-by-side under /dashboard:
- /dashboard/analytics
- /dashboard/notifications
You create folders
How do you configure the layout to render both routes simultaneously?
- /dashboard/analytics
- /dashboard/notifications
You create folders
app/dashboard/analytics and app/dashboard/notifications each with page.tsx.How do you configure the layout to render both routes simultaneously?
Attempts:
2 left
💡 Hint
Parallel routes use special folder names with @ and named slots in layouts.
✗ Incorrect
Next.js App Router supports parallel routes by using folders prefixed with @ and matching named components in layouts to render multiple routes simultaneously.