Careeroza
File Conventions
Special Files
| File | Purpose | Level taught |
|---|---|---|
page.tsx | UI of a route; makes the route public | Basic |
layout.tsx | Shared UI that wraps child routes, keeps state | Basic |
template.tsx | Like a layout but re-mounts on every navigation | Basic |
loading.tsx | Instant loading UI (Suspense fallback) | Medium |
error.tsx | Error boundary for the segment | Medium |
not-found.tsx | UI for notFound() and unknown URLs | Medium |
route.ts | API endpoint (GET, POST...) instead of a page | Medium |
default.tsx | Fallback for parallel route slots | Advance |
middleware.ts / proxy.ts | Runs before requests (project root) | Medium |
Special Folder Names
| Pattern | Meaning | Example URL |
|---|---|---|
[id] | Dynamic segment | /products/42 |
[...slug] | Catch-all | /docs/a/b/c |
[[...slug]] | Optional catch-all | /shop and /shop/a/b |
(shop) | Route group: organises files, not in the URL | /cart |
_components | Private folder: never a route | — |
@modal | Parallel route slot | — |
Render Order
<Layout>
<Template>
<ErrorBoundary fallback={<Error/>}> (error.tsx)
<Suspense fallback={<Loading/>}> (loading.tsx)
<ErrorBoundary fallback={<NotFound/>}> (not-found.tsx)
<Page/>