colocation
Keeping files that belong together, such as a page, its components and its tests, in the same folder.
In more detail
Colocated files are easy to find, change and delete together. The opposite is grouping by type, such as all components in one folder, far from where they are used.
Example
In the App Router a folder only becomes public when it has a page or route file, so colocated helpers are safe.Related terms
- private folder — A folder whose name starts with an underscore, such as _components, which the router ignores entirely.
- app directory — The folder, app/ or src/app/, whose subfolders and special files define every route in an App Router project.
Taught in
- Client Components: use client & Hydration Models — Next.js 15 & Modern App Router Architecture
- Route Groups & Private Folders: Modular Structures — Next.js 15 & Modern App Router Architecture
- Route Handlers: RESTful Endpoints with NextRequest — Next.js 15 & Modern App Router Architecture