Routing based on the app/ directory (file-system routing).

Core Concepts

File-based Routing

File / Folder Route
app/page.tsx /
app/about/page.tsx /about
app/blog/[slug]/page.tsx /blog/:slug (dynamic route)
app/@sidebar/layout.tsx Named parallel route segment
app/page.tsx + layout.tsx Nested layout + page combo

Server vs Client Components

Server Component Client Component
Default in App Router Yes No (opt-in)
Browser API access No Yes
React state/hooks No Yes
Requires "use client” No Yes

Layout System

// app/layout.tsx
export default function RootLayout({ children }: { children: React.ReactNode }) {
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  )
}

Special Files

File Purpose
layout.tsx Shared layout for a route segment
page.tsx Defines a routable page
loading.tsx Suspense fallback for async content
error.tsx Error boundary for the route segment
not-found.tsx Custom 404 page for the route segment
favicon.ico Site icon, placed under app/

Key Features