Project Structure

This page provides an overview of the file and folder structure of a Next.js project. It covers top-level files and folders, configuration files, and routing conventions within the app and pages directories.

This page contents are inspired from NextJS's official documentation. (here)

Top Level Folders

appApp Router
pagespages Router
publicStatic assets
src Optional application source folder

Top Level Files

next.config.jsConfiguration file for Next.js
package.jsonProject dependencies and scripts
.gitignoreGit files and folders to ignore
next-env.d.tsTypeScript declaration file for Next.js
jsconfig.json | tsconfig.json Configuration file for JavaScript/TypeScript
tailwind.config.js Configuration file for Taildwind Css.
.eslintrc.json Configuration file for ESLint
README.md Readme File for GitHub.

Routing Files

layout.js.jsx.ts.tsxLayout
page.js.jsx.ts.tsxPage
loading.js.jsx.ts.tsxLoading UI
error.js.jsx.ts.tsxError UI
route.js.tsAPI Endpoint
default.js.jsx.ts.tsxParallel route fallback page
not-found.js.jsx.ts.tsxNot Found UI

Nested Routes

folderRoute Segment
folder/folderNested Route Segment

Dynamic Routes

[folder]Dynamic Route Segment
[...folder]Catch-all route segment
[[...folder]]Optional Catch-all route segment

Warning : All of these above are only applicable for latest App Router (Next v13+)