The components defined in special files are rendered in a specific hierarchy:
layout.js
template.js
error.js
(React error boundary)loading.js
(React suspense boundary)not-found.js
(React error boundary)page.js
or nested layout.js
The components are rendered recursively in nested routes, meaning the components of a route segment will be nested inside the components of its parent segment.
In the app
directory, nested folders define route structure. Each folder represents a route segment that is mapped to a corresponding segment in a URL path.
Private folders can be created by prefixing a folder with an underscore: _folderName
This indicates the folder is a private implementation detail and should not be considered by the routing system, thereby opting the folder and all its subfolders out of routing.
Route groups can be created by wrapping a folder in parenthesis: (folderName)
This indicates the folder is for organizational purposes and should not be included in the route's URL path.