Next.js provides a clean and organized project structure that helps developers build scalable and maintainable applications. Below is an overview of the commonly used Next.js project structure (App Router).
The core directory used for routing and rendering.
page.js – Defines a route and renders UI for that page
layout.js – Shared layout across pages (header, footer, etc.)
loading.js – Loading UI while page data is being fetched
error.js – Handles runtime errors in routes
not-found.js – Custom 404 page
globals.css – Global styles for the application
Contains reusable UI components such as buttons, headers, cards, and forms.
Stores static assets like images, fonts, icons, and videos. Files here are directly accessible via URL.
Used for CSS files, CSS Modules, or other styling-related files (if not using Tailwind).
Contains utility functions, API helpers, database connections, and shared logic.
Custom React hooks used across the application.
next.config.js – Next.js configuration settings
package.json – Project dependencies and scripts
jsconfig.json / tsconfig.json – Path aliases and TypeScript configuration
.env.local – Environment variables
Older Next.js versions use the pages/ directory:
Note: The App Router (
app/) is recommended for new projects.
The Next.js project structure is designed to be modular, scalable, and easy to maintain. Understanding this structure helps you organize code efficiently and build large applications with confidence.
Take quizzes related to this topic and see where you stand!
Start Quiz Now