Nozioni di base su pagine, layout e routing
Esplori l'App Router, definisca le pagine, crei layout condivisi e navighi tra le route dell'applicazione.
Nozioni di base su pagine, layout e routing è una lezione Next.js 15 Fullstack Web Apps gratuita su CoddyKit. Questa è la lezione 3 di 4. Puoi leggere la lezione completa qui gratuitamente — poi esercitati direttamente nel browser con un editor di codice integrato e un tutor IA disponibile 24/7. Fa parte del percorso di apprendimento Next.js 15 Fullstack Web Apps, e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Next.js 15 Fullstack Web Apps include 4 lezioni in totale.
Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.
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.
Domande Frequenti
La lezione «Nozioni di base su pagine, layout e routing» è gratuita?
Sì — il testo completo di «Nozioni di base su pagine, layout e routing» è gratuito qui sul web. Per esercitarvi in modo interattivo (un editor di codice integrato e un tutor IA 24/7) e sbloccare il resto del corso Next.js 15 Fullstack Web Apps, passa a CoddyKit PRO. Il corso Next.js 15 Fullstack Web Apps include 4 lezioni in totale.
Cosa imparerò in «Nozioni di base su pagine, layout e routing»?
Esplori l'App Router, definisca le pagine, crei layout condivisi e navighi tra le route dell'applicazione. Eserciti Next.js 15 Fullstack Web Apps con codice pratico che esegui direttamente nel browser, e un tutor IA 24/7 risponde alle tue domande mentre lavori sulla lezione.
Ho bisogno di esperienza per iniziare Next.js 15 Fullstack Web Apps?
Non è richiesta alcuna esperienza precedente. Next.js 15 Fullstack Web Apps su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 3 di 4.
Quanto tempo richiede la lezione «Nozioni di base su pagine, layout e routing»?
La maggior parte delle lezioni CoddyKit richiede circa 5–10 minuti. Ogni lezione è breve e interattiva, quindi fai progressi costanti e riprendi esattamente da dove hai lasciato su web e app.
Posso scrivere ed eseguire codice in questa lezione Next.js 15 Fullstack Web Apps?
Sì. Ogni lezione Next.js 15 Fullstack Web Apps include un editor di codice integrato, quindi scrivi ed esegui codice reale direttamente nel tuo browser e ricevi feedback istantaneo dall'IA — nessuna configurazione locale necessaria.
Tutte le lezioni di questo corso
- Introduzione a Next.js 15
- Configurazione e impostazione del progetto
- Nozioni di base su pagine, layout e routing
- Metadati, SEO e head del documento