Capítulo 288 de 456
Full reference of folder and file conventions for a Next.js project, focused on Pages Router routing/file conventions plus shared top-level files.
app: App Router root.pages: Pages Router root.public: static assets served as-is.src: optional application source folder._app: custom App file (.js/.jsx/.tsx)._document: custom Document file._error: custom error page.404 / 500: dedicated error pages.index (folder or file): home/nested page via file-system routing.[folder]/[file]: dynamic route segment.[...folder]/[...file]: catch-all route segment.[[...folder]]/[[...file]]: optional catch-all route segment.| Top-level file | Purpose |
|---|---|
next.config.js | Next.js configuration |
package.json | Dependencies and scripts |
instrumentation.ts | OpenTelemetry/Instrumentation |
proxy.ts | Request proxy (formerly middleware) |
.env / .env.local / .env.production / .env.development | Environment variables (untracked) |
eslint.config.mjs | ESLint config |
.gitignore | Git ignore rules |
next-env.d.ts | TypeScript declarations for Next.js (untracked) |
tsconfig.json / jsconfig.json | TS/JS config |
| Route convention | Meaning |
|---|---|
index / folder/index | Home page / nested page |
file | Nested page |
[folder]/index or [file] | Dynamic route segment |
[...folder]/index or [...file] | Catch-all route segment |
[[...folder]]/index or [[...file]] | Optional catch-all route segment |
index files and [bracket] syntax define the entire route table, no explicit route registration._app, _document, _error, 404, 500 are the fixed set of special files the Pages Router recognizes at the pages/ root.next.config.js, .env*, tsconfig.json) are shared infrastructure regardless of App vs Pages Router.proxy.ts is the current name for what was formerly middleware.ts — same top-level convention slot._app.tsx/_document.tsx are shown in full code.