Next.js 15 Fullstack (App Router + Server Actions) · Aula

Grupos de Rotas e Layouts Aninhados

Organize projetos complexos do Roteador de Aplicações usando grupos de rotas, layouts aninhados e arquivos de modelo para interfaces compartilhadas e específicas de cada seção.

Aula 4 de 413 etapas

Grupos de Rotas e Layouts Aninhados é uma aula grátis de Next.js 15 Fullstack (App Router + Server Actions) no CoddyKit. Esta é a aula 4 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Next.js 15 Fullstack (App Router + Server Actions), e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Next.js 15 Fullstack (App Router + Server Actions) inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

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.

Grátis para começar

Aprenda TypeScript com um tutor de IA — grátis

Escreva e execute código real no seu navegador, obtenha ajuda instantânea de um tutor de IA 24/7 e continue de onde parou na web ou no app.

Cursos
22
Aulas
88

Perguntas Frequentes

A aula “Grupos de Rotas e Layouts Aninhados” é grátis?

Sim — o texto completo de “Grupos de Rotas e Layouts Aninhados” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Next.js 15 Fullstack (App Router + Server Actions), atualize para CoddyKit PRO. O curso de Next.js 15 Fullstack (App Router + Server Actions) inclui 4 aulas no total.

O que vou aprender em “Grupos de Rotas e Layouts Aninhados”?

Organize projetos complexos do Roteador de Aplicações usando grupos de rotas, layouts aninhados e arquivos de modelo para interfaces compartilhadas e específicas de cada seção. Você pratica Next.js 15 Fullstack (App Router + Server Actions) com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Next.js 15 Fullstack (App Router + Server Actions)?

Nenhuma experiência prévia é necessária. Next.js 15 Fullstack (App Router + Server Actions) no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 4 de 4.

Quanto tempo leva a aula “Grupos de Rotas e Layouts Aninhados”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Next.js 15 Fullstack (App Router + Server Actions)?

Sim. Cada aula de Next.js 15 Fullstack (App Router + Server Actions) inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Layouts e componentes de página
  2. Rotas dinâmicas e parâmetros
  3. Interfaces de carregamento e erro
  4. Grupos de Rotas e Layouts Aninhados
← Voltar para Next.js 15 Fullstack (App Router + Server Actions)