Nuxt Layers use a merging strategy for configuration files, including arrays like the list of component directories. When multiple layers define arrays (such as the components array in nuxt.config.ts), Nuxt merges these arrays rather than simply overwriting them. This means that component directories from all layers are combined, not replaced by the last one.
Specifically, the merging is handled by unjs/defu, which merges arrays and objects in a way that preserves entries from all layers unless explicitly overridden. For arrays, the order is important: earlier layers (closer to the root project) have higher priority and can override later ones if there are conflicts, but generally, all specified directories are included in the final configuration. The user's project is the first item in the layers array, so its configuration has the highest priority, but merging still occurs for arrays like components directories unless you explicitly overwrite them with a new value instead of extending.
You do not need to manually add all component paths from each layer into your root project’s config. If each layer defines its own components directory in its nuxt.config.ts, Nuxt will merge these configurations, and all component directories will be available in the final project. This allows you to build up a set of component directories across multiple layers without manual aggregation in the root config.
This merging behavior is confirmed in the documentation and recent fixes to ensure correct order and merging of array-type configs in layers fix(nuxt): ensure layer array-type config is merged in order, and is also described in the Nuxt docs on layers and configuration merging Going Deeper.