0
0
NextJSframework~20 mins

Project structure overview in NextJS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Next.js Project Structure Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the purpose of the app directory in Next.js 14?
In Next.js 14, what is the main role of the app directory in a project?
AIt holds configuration files like <code>next.config.js</code> and environment variables.
BIt contains server components and routes that define the app's UI and navigation.
CIt stores static assets like images and fonts for the project.
DIt is used only for API routes and backend logic.
Attempts:
2 left
💡 Hint
Think about where you define pages and layouts in Next.js 14.
component_behavior
intermediate
2:00remaining
What happens if you place a page file outside the app directory?
In a Next.js 14 project, what will happen if you create a page file like page.tsx outside the app directory?
AThe page will not be recognized and will not be part of the routing system.
BThe page will work normally and be accessible via URL.
CNext.js will throw a build error preventing the app from running.
DThe page will be treated as an API route.
Attempts:
2 left
💡 Hint
Where does Next.js expect page files in the new app router?
📝 Syntax
advanced
2:00remaining
Identify the correct file to define a layout for all pages in Next.js 14
Which file should you create inside the app directory to define a layout that wraps all pages in your Next.js 14 app?
A<code>page.tsx</code>
B<code>app.tsx</code>
C<code>layout.tsx</code>
D<code>root.tsx</code>
Attempts:
2 left
💡 Hint
Layouts wrap pages and share UI like headers or footers.
🔧 Debug
advanced
2:00remaining
Why does this Next.js 14 project fail to load the homepage?
Given this project structure: - app/ - layout.tsx - home.tsx Why does the homepage not load at the root URL?
ABecause the homepage file must be named <code>page.tsx</code>, not <code>home.tsx</code>.
BBecause <code>layout.tsx</code> is missing a default export.
CBecause the <code>app</code> directory must be named <code>pages</code>.
DBecause the <code>home.tsx</code> file must be inside a folder named <code>home</code>.
Attempts:
2 left
💡 Hint
Next.js uses specific file names for routing.
lifecycle
expert
3:00remaining
How does Next.js 14 handle server and client components in the app directory?
In Next.js 14, how does the framework decide which components in the app directory run on the server versus the client?
ANext.js runs all components on both server and client automatically without distinction.
BAll components run on the client unless wrapped in a special <code>ServerComponent</code> tag.
CComponents run on the server or client based on their file extension: <code>.server.tsx</code> or <code>.client.tsx</code>.
DBy default, components are server components unless marked with <code>'use client'</code> at the top to run on the client.
Attempts:
2 left
💡 Hint
Look for a special directive string at the top of files.