Project Structure and Organization
Source URL: https://nextjs.org/docs/pages/getting-started/project-structure
Project Structure and Organization
Section titled “Project Structure and Organization”This page provides an overview of all the folder and file conventions in Next.js, and recommendations for organizing your project.
Folder and file conventions
Section titled “Folder and file conventions”Top-level folders
Section titled “Top-level folders”Top-level folders are used to organize your application’s code and static assets.

app | App Router |
pages | Pages Router |
public | Static assets to be served |
src | Optional application source folder |
Top-level files
Section titled “Top-level files”Top-level files are used to configure your application, manage dependencies, run proxy, integrate monitoring tools, and define environment variables.
| Next.js | |
next.config.js | Configuration file for Next.js |
package.json | Project dependencies and scripts |
instrumentation.ts | OpenTelemetry and Instrumentation file |
proxy.ts | Next.js request proxy |
.env | Environment variables (should not be tracked by version control) |
.env.local | Local environment variables (should not be tracked by version control) |
.env.production | Production environment variables (should not be tracked by version control) |
.env.development | Development environment variables (should not be tracked by version control) |
eslint.config.mjs | Configuration file for ESLint |
.gitignore | Git files and folders to ignore |
next-env.d.ts | TypeScript declaration file for Next.js (should not be tracked by version control) |
tsconfig.json | Configuration file for TypeScript |
jsconfig.json | Configuration file for JavaScript |
File conventions
Section titled “File conventions”_app | .js .jsx .tsx | Custom App |
_document | .js .jsx .tsx | Custom Document |
_error | .js .jsx .tsx | Custom Error Page |
404 | .js .jsx .tsx | 404 Error Page |
500 | .js .jsx .tsx | 500 Error Page |
Routes
Section titled “Routes”| Folder convention | ||
index | .js .jsx .tsx | Home page |
folder/index | .js .jsx .tsx | Nested page |
| File convention | ||
index | .js .jsx .tsx | Home page |
file | .js .jsx .tsx | Nested page |
Dynamic routes
Section titled “Dynamic routes”| Folder convention | ||
[folder]/index | .js .jsx .tsx | Dynamic route segment |
[...folder]/index | .js .jsx .tsx | Catch-all route segment |
[[...folder]]/index | .js .jsx .tsx | Optional catch-all route segment |
| File convention | ||
[file] | .js .jsx .tsx | Dynamic route segment |
[...file] | .js .jsx .tsx | Catch-all route segment |
[[...file]] | .js .jsx .tsx | Optional catch-all route segment |