0Pricing
Next.js 15 Fullstack (App Router + Server Actions) · Lezione

Gruppi di route e layout annidati

Organizzi progetti complessi con App Router usando gruppi di route, layout annidati e file template per un’interfaccia condivisa e specifica per ogni sezione.

Gruppi di route e layout annidati è una lezione Next.js 15 Fullstack (App Router + Server Actions) gratuita su CoddyKit. Questa è la lezione 4 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 (App Router + Server Actions), e i tuoi progressi si sincronizzano tra il web e l'app CoddyKit. Il corso Next.js 15 Fullstack (App Router + Server Actions) include 4 lezioni in totale.

Parti di questa lezione non sono ancora state tradotte e vengono mostrate in inglese.

Why Organization Matters

As an app grows, the App Router lets you structure folders for shared UI without affecting the URL. Route groups and nested layouts are the main tools.

Nested Layouts Recap

Each folder can have a layout.tsx. Layouts nest: a section layout wraps its pages while the root layout wraps everything.

export default function DashboardLayout({ children }) {
  return (<section><nav>Dashboard nav</nav>{children}</section>);
}

Route Groups

Wrapping a folder name in parentheses, like (marketing), creates a route group. It organizes files but is omitted from the URL.

Multiple Root Layouts

Route groups let you have different top-level layouts — for example, one for marketing pages and another for the app — by giving each group its own layout.

app/
  (marketing)/layout.tsx
  (marketing)/page.tsx
  (app)/layout.tsx
  (app)/dashboard/page.tsx

URLs Stay Clean

Because (marketing) does not appear in the path, app/(marketing)/page.tsx still serves the URL /, not /marketing.

Template vs Layout

A template.tsx is like a layout but creates a new instance on every navigation, resetting state — useful for enter animations or per-route effects.

export default function Template({ children }) {
  return <div className="fade-in">{children}</div>;
}

When to Use Template

Use a template when you need state or effects to re-run on each navigation; use a layout when you want shared UI and state to persist across navigations.

Organizing Without Routing

You can also use route groups purely to colocate related routes under one folder without adding a URL segment, keeping the codebase tidy.

Shared UI in Layouts

Put navigation, sidebars, and providers in the nearest layout so they persist and avoid re-rendering on navigation within that section.

Loading and Error per Section

Each segment, including grouped ones, can have its own loading.tsx and error.tsx, scoping fallback UI precisely.

Putting It Together

A typical app: a (marketing) group with a public layout, an (app) group with an authenticated layout, each nesting further section layouts.

Quick Check

What does wrapping a folder name in parentheses do?

Recap

You learned to structure apps with nested layouts for persistent shared UI, route groups (name) that organize without changing URLs and allow multiple root layouts, and templates that remount on navigation.

Domande Frequenti

La lezione «Gruppi di route e layout annidati» è gratuita?

Sì — il testo completo di «Gruppi di route e layout annidati» è 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 (App Router + Server Actions), passa a CoddyKit PRO. Il corso Next.js 15 Fullstack (App Router + Server Actions) include 4 lezioni in totale.

Cosa imparerò in «Gruppi di route e layout annidati»?

Organizzi progetti complessi con App Router usando gruppi di route, layout annidati e file template per un’interfaccia condivisa e specifica per ogni sezione. Eserciti Next.js 15 Fullstack (App Router + Server Actions) 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 (App Router + Server Actions)?

Non è richiesta alcuna esperienza precedente. Next.js 15 Fullstack (App Router + Server Actions) su CoddyKit è strutturato per principianti e studenti avanzati, quindi puoi iniziare da qui o dall'inizio e procedere al tuo ritmo. Questa è la lezione 4 di 4.

Quanto tempo richiede la lezione «Gruppi di route e layout annidati»?

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 (App Router + Server Actions)?

Sì. Ogni lezione Next.js 15 Fullstack (App Router + Server Actions) 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

  1. Layout e componenti di pagina
  2. Route dinamiche e parametri
  3. Interfaccia di caricamento ed errori
  4. Gruppi di route e layout annidati
← Torna a Next.js 15 Fullstack (App Router + Server Actions)