0
0
NextJSframework~30 mins

Project structure overview in NextJS - Mini Project: Build & Apply

Choose your learning style9 modes available
Next.js Project Structure Overview
📖 Scenario: You are starting a new Next.js project to build a simple website. Understanding the project structure helps you organize your files and code properly.
🎯 Goal: Learn the basic Next.js project structure by creating the main folders and files needed for a simple app.
📋 What You'll Learn
Create the app folder as the main directory for pages
Add a page.tsx file inside app with a simple component
Create a layout.tsx file inside app to define the page layout
Add a globals.css file inside app for global styles
💡 Why This Matters
🌍 Real World
Next.js projects use this structure to organize pages, layouts, and styles for scalable web apps.
💼 Career
Understanding Next.js project structure is essential for frontend developers working with React and modern web frameworks.
Progress0 / 4 steps
1
Create the app folder and page.tsx file
Create a folder named app and inside it create a file named page.tsx. In page.tsx, write a React functional component called Page that returns an <h1> with the text Welcome to Next.js.
NextJS
Need a hint?

Use export default function Page() and return an <h1> element with the exact text.

2
Add a layout.tsx file inside app
Inside the app folder, create a file named layout.tsx. Write a React functional component called RootLayout that accepts a children prop of type React.ReactNode and returns an <html> element containing a <body> that renders the children.
NextJS
Need a hint?

Define RootLayout with a children prop and wrap it inside <html lang="en"> and <body>.

3
Create a globals.css file for global styles
Inside the app folder, create a file named globals.css. Add a CSS rule that sets the body background color to #f0f0f0 and the font family to Arial, sans-serif.
NextJS
Need a hint?

Write CSS inside globals.css to style the body background and font.

4
Import globals.css in layout.tsx
At the top of the layout.tsx file inside app, add an import statement to import ./globals.css so the global styles apply to the app.
NextJS
Need a hint?

Use import './globals.css'; at the top of layout.tsx.