Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Route Groups and Organization Basics | Section
Практика
Проекти
Вікторини та виклики
Вікторини
Виклики
/
Building Web Apps with Next.js

bookRoute Groups and Organization Basics

Свайпніть щоб показати меню

As your application grows, the app/ folder can become large and harder to manage. You may want to organize your files into logical groups without affecting the URL structure.

Next.js provides route groups for this purpose.

Route groups allow you to group related routes together in folders without adding those folders to the URL.

Creating a Route Group

To create a route group, wrap the folder name in parentheses.

Example:

app/
  (marketing)/
    about/
      page.tsx
    contact/
      page.tsx

What URLs This Creates

Even though the files are inside (marketing), the URLs remain: /about, /contact.

The (marketing) folder does not appear in the URL.

Why Use Route Groups

  • Organize large applications into logical sections;
  • Separate different parts of the app (e.g. marketing vs dashboard);
  • Keep the URL clean and user-friendly;
  • Improve maintainability without changing routing.

Example - Separating App Areas

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

This creates routes like:

  • /;
  • /about;
  • /dashboard.

Even though the structure is grouped internally.

When to Use Route Groups

Use route groups when:

  • Your project becomes large;
  • You want to separate concerns (e.g. public vs authenticated areas);
  • You need better organization without changing URLs.
question mark

What is the purpose of route groups in Next.js?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 10

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Секція 1. Розділ 10
some-alt