Loading content...
Loading content...
This defines how your project files and folders are organized
Used to organize code and assets:
app/ → App Router
pages/ → Pages Router
public/ → Static files (images, fonts)
src/ → Optional source folder
Important config files:
package.json → dependencies & scripts
next.config.js → Next.js config
.env → environment variables
tsconfig.json → TypeScript config
.gitignore → ignored files
Special files for routing:
FilePurposepage.tsxPage UIlayout.tsxShared layoutloading.tsxLoading UIerror.tsxError UIroute.tsAPI route
Folder = URL path
plaintext
app/
├── page.tsx → /
├── blog/
│ └── page.tsx → /blog✔ Folders create routes automatically
👉 Use [ ] for dynamic URLs:
plaintext
app/blog/[slug]/page.tsx👉 Example:
plaintext
/blog/my-postTypeExampleDynamic[slug]Catch-all[...slug]Optional[[...slug]]
👉 Organize folders without changing URL:
plaintext
app/(marketing)/page.tsx → /✔ (folder) is NOT in URL
👉 Prefix _ to make non-routable:
plaintext
app/blog/_components/✔ Used for:
Components
Utils
Internal logic
👉 Use @folder for multiple UI sections
👉 Show one route inside another (like modal)
👉 Rendering order:
plaintext
layout → template → error → loading → page👉 Static files:
plaintext
public/image.png → /image.pngSEO & icons:
favicon.ico
sitemap.xml
robots.txt
opengraph-image.png
You can organize in 3 ways:
app/Keep logic in root folders
app/Keep everything in app folder
Split by feature or route
Folder = Route
page.tsx = public route
_folder = private
(folder) = group (no URL change)