# Route Groups (...)

> Organizing folders and layouts without changing URLs.

Subject: Next.js | Lesson 17 of 65 | 4 min read
Interactive lesson: https://codewithanimation.in/nextjs/route-groups
Previous: [Optional Catch-all ([[...slug]])](https://codewithanimation.in/nextjs/optional-catch-all.md) | Next: [Parallel Routes (@slot)](https://codewithanimation.in/nextjs/parallel-routes.md)

## The invisible folders

In the App Router, every folder you create normally becomes a segment in the URL.

But sometimes you just want to organize your code visually, or group files together. If you wrap a folder name in parentheses—like `(marketing)` or `(shop)`—Next.js treats it as a **Route Group**. The folder becomes completely invisible to the URL.

## Multiple layouts

The most powerful feature of Route Groups is layout scoping.

If you want your `/about` page to have a clean, marketing-focused layout, but your `/dashboard` page to have a complex sidebar layout, you can create `app/(marketing)/layout.tsx` and `app/(app)/layout.tsx`. Both layouts exist at the root URL level, but they only apply to the routes inside their respective groups.

## Stripping the path

If you create the file `app/(marketing)/about/page.tsx`, the resulting URL is simply `/about`.

If you create `app/(shop)/checkout/page.tsx`, the URL is `/checkout`. The grouping folders are entirely stripped away during routing.

## Common mistake: Accidental 404s

A common beginner mistake is forgetting that Route Groups are stripped from the URL.

If you build `app/(admin)/users/page.tsx`, and then try to navigate to `/admin/users` in your browser to see it, you will get a 404 error. The correct URL is just `/users`.

## Tip: Multiple root layouts

You can actually delete the top-level `app/layout.tsx` file and replace it with multiple Root Layouts inside Route Groups.

Just create `app/(marketing)/layout.tsx` and `app/(shop)/layout.tsx`. Both must include `<html>` and `<body>` tags. This allows entirely different HTML structures for different parts of your site.

## Try it: The Invisible Folder

Watch the auto-demo strip the parenthesis folders away. Notice how `(marketing)` and `(shop)` both contribute to the same root URL level, while maintaining their own isolated layouts.

The animation is on the lesson page and is not part of this text version: https://codewithanimation.in/nextjs/route-groups

## Check yourself

### Question 1

If you create a file at app/(admin)/settings/security/page.tsx, what is the correct URL to access this page?

- A. /(admin)/settings/security
- B. /admin/settings/security
- C. /settings/security
- D. /security

Correct answer: C

Next.js completely ignores folders wrapped in parentheses when generating the URL path, leaving only the standard folders.

- Why not A: The parentheses tell Next.js to ignore the folder.
- Why not B: Next.js strips the entire Route Group from the URL, not just the parentheses.
- Why not D: The settings folder is a standard folder, so it is kept.

### Question 2

What is the primary architectural use-case for Route Groups in Next.js?

- A. To prevent certain pages from being indexed by search engines
- B. To opt-out of the Next.js cache
- C. To apply different layouts to routes at the same URL hierarchy level
- D. To catch all unmatched URLs

Correct answer: C

Route Groups let you partition your application into different sections (like marketing vs dashboard), allowing you to apply specific layouts to those sections without affecting the URL.

- Why not A: Route groups have no impact on SEO or robots.txt.
- Why not B: Caching is controlled via fetch options or route segment config, not folder names.
- Why not D: That is the job of catch-all routes ([...slug]).

## Remember this

- Wrap a folder in parentheses `(folderName)` to create a Route Group.
- Route Groups are completely ignored by the Next.js router when building the URL.
- They are primarily used to organize code and scope layouts to specific sets of pages.
- You can use Route Groups to create multiple distinct Root Layouts.
