Sikau

Next.js · Day 2 · about 25 min

Routes and folders

Nested routes, route groups and private folders.

A site map you can see

In Next.js your folder tree *is* your site map. Reading app/ tells you every URL in the project — no separate routing config to keep in sync.

Folder conventions

export default function AboutPage() {
  return (
    <article>
      <h1>About us</h1>
      <p>Family-run since 1998.</p>
    </article>
  );
}
  • Nested routes: app/about/team/page.jsx → /about/team.
  • Route groups (name) organise files without changing URLs: app/(marketing)/pricing/page.jsx → /pricing.
  • Private folders _name are never routes — handy for components: app/_components/Card.jsx.
  • Files other than special ones (page, layout, loading, error, not-found, route…) can sit next to pages safely — only page.jsx is public.

The rest of this lesson

  • Colocation: keeping files togetherexplain
  • The special filesexplain
  • Which URL?predict
  • Group URLpredict
  • Your turnwrite code
  • Badge quizquiz
  • What you learnedrecap

Continue this lesson free — run real code in your browser

Continue with Google

See all 19 lessons of Next.js