ページ、レイアウト、ルーティングの基礎
App Routerを使い、ページの定義、共有レイアウトの作成、アプリケーション内のルート間の移動を学びます。
「ページ、レイアウト、ルーティングの基礎」はCoddyKit上の無料Next.js 15 Fullstack Web Appsレッスンです。 これはレッスン3/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはNext.js 15 Fullstack Web Apps学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 Next.js 15 Fullstack Web Appsコースには全4レッスンが含まれています。
このレッスンの一部はまだ翻訳されておらず、英語で表示されています。
Welcome to App Router
The App Router is Next.js 15's routing system, built on React Server Components. It lets you co-locate components, styles, and tests by route.
Routes from Your Files
Routing is filesystem-based: your folder structure inside app/ directly defines your URLs, keeping the project predictable.
Defining a Page
A page.js file inside a folder makes that route render. It exports the React component shown when a user visits that URL.
Code: Simple Page
Create app/page.js and it automatically becomes your home page at the / route. Here is the component that renders there.
export default function HomePage() {
return (
<div>
<h1>Welcome to CoddyKit!</h1>
<p>This is your Next.js home page.</p>
</div>
);
}Organizing with Nested Routes
Build nested routes by nesting folders in app/ — each folder is a URL segment, so app/dashboard/settings/ maps to /dashboard/settings.
Code: Nested Page
To serve /dashboard/settings, create that folder path with a page.js inside. The file's component renders at that URL.
// app/dashboard/settings/page.js
export default function DashboardSettingsPage() {
return (
<div>
<h2>Dashboard Settings</h2>
<p>Manage your preferences here.</p>
</div>
);
}Shared UI with Layouts
A layout (layout.js) is shared UI that wraps the pages in its segment — ideal for navbars, sidebars, and footers via the children prop.
Code: Root Layout
Every App Router project needs a root layout.js. It defines the base HTML — the <html> and <body> tags around your whole app.
// app/layout.js
import './globals.css'; // Global styles (optional)
export default function RootLayout({ children }) {
return (
<html lang="en">
<body>
<header>
<nav>Home | About</nav>
</header>
<main>{children}</main> {/* Page content goes here */}
<footer>© 2024 CoddyKit</footer>
</body>
</html>
);
}Nested Layouts
Nested layouts apply only to their folder and subfolders, inheriting from parent layouts — so you can build hierarchical UI per section.
Linking Between Pages
Navigate with the <Link> component from next/link. It behaves like an anchor but does client-side routing — no full page reload.
// app/page.js (example usage)
import Link from 'next/link';
export default function HomePage() {
return (
<div>
<h1>Welcome!</h1>
<p>Go to the <Link href="/about">About Us</Link> page.</p>
<p>Or visit your <Link href="/dashboard">Dashboard</Link>.</p>
</div>
);
}Routing & Layouts Check
Which of the following statements about Next.js 15 App Router are TRUE?
Recap: Pages, Layouts & Routing
You learned the App Router: folders define routes, page.js renders content, layout.js shares UI, and <Link> handles fast navigation.
よくある質問
「ページ、レイアウト、ルーティングの基礎」レッスンは無料ですか?
はい。「ページ、レイアウト、ルーティングの基礎」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、Next.js 15 Fullstack Web Appsコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 Next.js 15 Fullstack Web Appsコースには全4レッスンが含まれています。
「ページ、レイアウト、ルーティングの基礎」で何を学びますか?
App Routerを使い、ページの定義、共有レイアウトの作成、アプリケーション内のルート間の移動を学びます。 ブラウザで直接実行するハンズオンコードでNext.js 15 Fullstack Web Appsを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。
Next.js 15 Fullstack Web Appsを始めるのに経験は必要ですか?
事前経験は必要ありません。CoddyKitのNext.js 15 Fullstack Web Appsは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン3/4です。
「ページ、レイアウト、ルーティングの基礎」レッスンにはどのくらい時間がかかりますか?
ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。
このNext.js 15 Fullstack Web Appsレッスンでコードを書いて実行できますか?
はい。すべてのNext.js 15 Fullstack Web Appsレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。
このコースのすべてのレッスン
- Next.js 15入門
- プロジェクトのセットアップと設定
- ページ、レイアウト、ルーティングの基礎
- メタデータ、SEO、ドキュメントヘッド