Route prefix for layers
is there any way to prefix layer routes ?
each layers has their own page router system, but in order to avoid collision on names i would like to add a route prefix for each layer... is this possible ?
The only way I found is to create a directory in the layer's pages dir.
However, it would be nice to use something like baseURL for layerBaseUrl.
2 Replies
Hi @zangetsu. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
Currently, Nuxt does not provide a built-in option like baseURL or layerBaseUrl to automatically prefix all routes from a specific layer. The recommended approach, as you mentioned, is to create a directory inside the layer’s pages directory (e.g., pages/admin/) to namespace the routes and avoid collisions. This way, all routes from that layer will be prefixed accordingly (e.g., /admin/your-page).
There is no documented configuration or property in Nuxt’s layers or routing system that allows you to set a route prefix for an entire layer automatically. The knowledge sources confirm that grouping pages in a subdirectory is the standard method for achieving route namespacing in layers, and no alternative or more automated solution is described at this time Custom Routing Layers.
If you need more advanced routing logic, you may need to customize the router or use Nuxt hooks, but there is no out-of-the-box layer route prefix feature.
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
<@745078500255596646> Kapa.ai is still learning and improving, please let me know how I did by reacting below.