Routing based on the app/
directory (file-system routing).
"use client"
layout.tsx
)loading.tsx
, React Suspense)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 |
page.tsx
: Defines a route entry pointlayout.tsx
: Defines shared UI across pages in the folderServer 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 |
"use client"
at the top of the file to enable client behaviorlayout.tsx
: Persistent UI wrapper (e.g. <nav>
, <footer>
)// app/layout.tsx
export default function RootLayout({ children }: { children: React.ReactNode }) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
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/ |