Most frameworks make you register routes in a configuration file. Next.js takes a different approach: the folder structure inside the app directory is the router. Create a folder, drop in a page file, and you have a live URL. This lesson teaches you how folders map to routes, how nesting works, and which special files the App Router recognizes.
Two rules explain almost everything:
Here is a small site and the URLs it produces:
app/
├── page.js → /
├── about/
│ └── page.js → /about
├── blog/
│ ├── page.js → /blog
│ └── first-post/
│ └── page.js → /blog/first-post
└── dashboard/
└── settings/
└── page.js → /dashboard/settingsNotice that /dashboard itself returns a 404 because the dashboard folder has no page.js - only its settings child does. Folders without a page file are purely organizational.
Create app/about/page.js:
// app/about/page.js
export default function AboutPage() {
return (
<main>
<h1>About Us</h1>
<p>We teach practical web development at CodeYourCraft.</p>
</main>
);
}Save the file and visit http://localhost:3000/about. No route registration, no config edits. The default export of page.js is the component rendered for that URL.
Inside any route folder, certain file names have reserved meanings:
You will meet layouts in the next lesson and route handlers later; for now, remember that these names are reserved and everything else (components, utils, styles) can live alongside them safely.
Because only special files affect routing, you can keep a component right next to the page that uses it:
app/blog/
├── page.js
├── PostCard.js ← not a route, just a component
└── posts.data.js ← not a route, just dataPostCard.js is never served as a URL. This colocation keeps features self-contained instead of scattering files across a giant components folder.
Sometimes you want to group folders without adding a URL segment. Wrap the folder name in parentheses:
app/
├── (marketing)/
│ ├── about/page.js → /about
│ └── pricing/page.js → /pricing
└── (shop)/
└── cart/page.js → /cartThe (marketing) and (shop) folders vanish from the URL. Route groups are perfect for giving different sections of a site different layouts, which we explore next lesson.
Prefix a folder with an underscore, like _components, and the router ignores it and everything inside it. This is a convention for utility folders you never want routed.
Next up: Lesson 4 covers pages, layouts, and templates - how shared UI persists across navigation.