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