Route Groups in Next.js

Route groups allow you to organize your project without affecting the URL.

How Route Groups Work?

Use parentheses () to group routes:

Example:


app/(auth)/
 ├─ login/
 │    └─ page.js       → /login
 └─ register/
      └─ page.js       → /register

Why Use Route Groups?

1. Better folder organization

2. Separate public/auth/admin sections

3. Apply different layouts to groups

4. Cleaner structure

Apply Layout to Only One Group

Each group gets its own layout while URLs remain clean.

Example:


app/(marketing)/layout.js
app/(main)/layout.js

Route Groups in Next.js – Interview Questions

Q 1: What are route groups?

Ans: Folders wrapped in parentheses ( ) that don’t affect URLs.

Q 2: Why use route groups?

Ans: To organize routes logically.

Q 3: Do route groups affect routing?

Ans: No, they are ignored in URLs.

Q 4: Can layouts be used in route groups?

Ans: Yes.

Q 5: Are route groups optional?

Ans: Yes.

Route Groups in Next.js – Objective Questions (MCQs)

Q1. What is the purpose of Route Groups in Next.js?






Q2. Which syntax is used for Route Groups?






Q3. Will Route Group names appear in the URL?






Q4. Route Groups are mainly used for:






Q5. Which router supports Route Groups?






Related Route Groups in Next.js Topics