Skip to main content

Command Palette

Search for a command to run...

Routing ~Private Folders~

Updated
1 min read
Routing  ~Private Folders~

In Next.js's App Router, a private folder is a feature that excludes a folder and its subfiles from URL routing by prefixing the folder name with an underscore (_) (e.g., _components). It is primarily used when creating and organizing files such as components, styles, and shared logic, allowing you to place them without affecting the URL structure.

Features and Main Uses

Routing Exclusion: Even if placed under the app directory, the page.js file within it will not be recognized as a URL.

File Organization: You can organize and manage page-specific components, CSS, and utility functions by keeping them in a physically close location (within a folder).

Naming Conventions: Start with an underscore, such as _folderName.

Examples of Use

app/
├── (auth)/
├── dashboard/
│   ├── _components/  <-- Private folder (not influence URL)
│   │   └── Chart.tsx
│   └── page.tsx      <-- access dashboard page by /dashboard
└── page.tsx