App Router & special files
Folders are routes. Special file names define the UI for each segment.
- page.tsx makes a segment public; layout.tsx wraps it and persists across navigations.
- loading.tsx is an automatic Suspense boundary; error.tsx is an error boundary (must be a Client Component); not-found.tsx renders for notFound().
- Route groups like (marketing) and (app) organise code and give each group its own layout without changing the URL.
- Dynamic segments: [id], catch-all [...slug], optional [[...slug]]. In Next 15+ params and searchParams are Promises.
See it in this app: src/app/(marketing), src/app/(app), src/app/(app)/projects/[id]
// app/(app)/projects/[id]/page.tsx
type Props = { params: Promise<{ id: string }> };
export default async function Page({ params }: Props) {
const { id } = await params;
return <h1>Project {id}</h1>;
}