The project structure
What each file and folder in a Next.js 16 project does, how a route becomes public, and how to colocate code with private folders and an optional src directory.
The project structure
The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.
Not started
What you'll learn
- The `app` folder holds your routes, `public` holds static files served from the site root, and `next.config.ts` configures the framework.
- A folder inside `app` is not reachable from a URL until it contains a `page` or `route` file, so you can keep components, helpers and tests next to the code that uses them.
- Special file names such as `layout`, `page`, `loading`, `error`, `not-found` and `route` are the framework's vocabulary, and they render in a fixed nesting order.
- Top-level files such as `proxy.ts`, `.env.local` and `instrumentation.ts` configure the whole app and live at the project root, next to `app`, not inside it.
Two kinds of things live in a project
Open the scaffold from the last lesson and everything falls into one of two groups: files that describe the whole application, and files that describe routes. Keeping those apart in your head makes the layout obvious.
Whole-application files sit at the project root:
package.jsonholds dependencies and scripts.next.config.tsconfigures Next.js itself. The scaffold already puts a few options here.tsconfig.jsonandnext-env.d.tsconfigure TypeScript.next-env.d.tsis generated; leave it alone and out of version control.eslint.config.mjsconfigures linting..env.local(you create it) holds secrets and per-machine settings. It must stay out of git, and the scaffold’s.gitignorealready covers it.proxy.ts(you create it, when you need it) runs before a request reaches a route. In Next.js 16 it replaces the oldermiddleware.ts.AGENTS.mdis the scaffold’s note to coding assistants.
Folders at the root: app for routes, public for static assets, and optionally pages if you use the legacy router. .next is build output created by the dev server and the build; it is git-ignored.
public is served from the root
A file at public/logo.svg is served at /logo.svg. The scaffold’s next.svg and vercel.svg are there for the starter page. Nothing in public goes through the bundler, so use it for files you want at a fixed URL, such as a favicon source, robots.txt or downloadable PDFs.
Inside app: the framework’s vocabulary
The files Next.js recognizes inside app have fixed names:
| File | Purpose |
|---|---|
layout |
UI shared by a segment and everything below it |
page |
The UI for a URL, which makes the segment reachable |
loading |
A fallback while the segment streams in |
error |
An error boundary for the segment |
not-found |
UI for a missing resource |
route |
An HTTP endpoint instead of a page |
template |
Like a layout, but remounts on navigation |
default |
A fallback for parallel routes |
They render in a fixed nesting: layout, then template, then error, then loading, then not-found, then the page or a deeper layout. You will use each in the lessons that follow.
A route is public only when you say so
This is the idea that makes the structure workable. Folders define URL segments, but a segment only becomes a URL when it contains a page or route file. Even then, only what page returns is sent to the browser. So this layout is safe:
app/
dashboard/
page.tsx → /dashboard
chart.tsx → not a route, just a component
format-date.ts → not a route, just a helper
You can colocate components, helpers and tests next to the route that uses them, or keep them outside app in folders like components/ and lib/. Both are fine. Pick one and be consistent. If you want an explicit marker, prefix a folder with an underscore, such as app/dashboard/_components/. That opts the folder and everything inside it out of routing entirely, and it avoids clashing with any file name Next.js might reserve later. Route groups and private folders covers this properly.
The optional src folder
If you chose a src/ directory at creation, app lives at src/app/, and your own components/ and lib/ can go next to it. Configuration files stay at the root. The one catch: .env files are still read from the project root, not from src/.
What the video covers
Codevolution’s chapters walk through package.json, the configuration files, the project folders (.next, node_modules, public and the source folder), and how they fit together. It was recorded for Next.js 15, so it predates proxy.ts replacing middleware.ts, and its starter page differs from the 16 scaffold. The files and folders it explains are still the right ones.
Where this fits
You can now read any Next.js project’s skeleton. Next, the App Router and the Pages Router explains why there is also a pages folder and which one to use.
Check yourself
If you add `app/dashboard/charts.tsx` and nothing else, is `/dashboard/charts` a working URL?
No. A route only exists when a segment contains a `page` file or a `route` file. `charts.tsx` is an ordinary module that happens to sit in a routing folder, so it can be imported but not visited.
What is the render order of the special files within one route segment?
`layout` wraps `template`, which wraps `error`, then `loading`, then `not-found`, and finally the `page` or a nested `layout`. Each one is an outer wrapper around the next.
Where should `proxy.ts` and `.env.local` go, and why not inside `app`?
They belong at the project root, beside `app`. They configure the whole application rather than one route segment, so they are not part of the routing tree.
Go deeper
Notes
Notes are saved to your account.
Everything else on this page works without one — progress and bookmarks keep themselves in this browser and come with you when you sign in. Notes are the one thing worth not trusting to a browser you might clear.
Your notes could not be loaded.