Grouped Layouts

Common purpose routes are often placed into directories so they can share layouts, and so related source files are logically grouped next to each other. However, it may be desirable that the directory, which was used to group similar files and share layouts, is excluded from the public-facing URL. This is where "grouped" layouts come in (also referred to as a "pathless" layout route).

By surrounding any directory name with parentheses, such as (name), then the directory name itself will not be included in the URL pathname.

For example, let's say an app placed all account routes together in a directory, however, /account/ could be dropped from the URL for cleaner, shorter URLs. In the example below, notice that the paths are within the src/routes/(account)/ directory. However, the URL paths exclude (account)/.

src/
โ””โ”€โ”€ routes/
    โ””โ”€โ”€ (account)/             # Notice the parentheses
        โ”œโ”€โ”€ layout.tsx         # Shared account layout
        โ””โ”€โ”€ profile/
            โ””โ”€โ”€ index.tsx      # https://example.com/profile
        โ””โ”€โ”€ settings/
            โ””โ”€โ”€ index.tsx      # https://example.com/settings
Made with โค๏ธ by