You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Warn in dev mode if nested route without <NuxtPage /> exists #25077
oh, I did just find a workaround. renaming [username].vue to [...slug.vue] and changing the code a bit works for all the URL's I showed in the repro case:
But even with that workaround, http://localhost:3000/myUser/myPage/abcd goes to [...slug.vue] which I don't really want. In that case I want 404. I guess I could just throw a 404 if slug is too long, but this still seems wrong.
I think you accidentally created a nested route. @danielroe do you think we should warn if a nested route without <NuxtPage> exists or do you have valid use cases of that in mind? 🤔
changed the title [-]Warn if nested route without `<NuxtPage />` exists[/-][+]Warn in dev mode if nested route without `<NuxtPage />` exists[/+]on Jan 7, 2024
heyy @manniL, is there a way to know if the parent route (same thing as the base route?) doesn't have the component? I'm looking at checking if a route has children and if it has the NuxtPage component. What do you think of this approach?
hi @manniL, I thought the best approach was to show devs when a route has children but the component isn't used in the base route/path but this won't work if you use the component in the app.vue file as it automatically works as if all other routes use this component. Another approach may be to just check if the user has multiple routes and doesn't use the component but this doesn't seem to greatly improve DX in any way to me. What do you think?
Activity
TheRoccoB commentedon Jan 6, 2024
oh, I did just find a workaround. renaming [username].vue to [...slug.vue] and changing the code a bit works for all the URL's I showed in the repro case:
But even with that workaround, http://localhost:3000/myUser/myPage/abcd goes to [...slug.vue] which I don't really want. In that case I want 404. I guess I could just throw a 404 if slug is too long, but this still seems wrong.
TheRoccoB commentedon Jan 6, 2024
OK this new directory structure actually works in all cases:
It still seems though that my original attempt should either throw an error telling you what to do (or work).
Guess I needed to talk to the duck.
TheAlexLichter commentedon Jan 6, 2024
I think you accidentally created a nested route. @danielroe do you think we should warn if a nested route without
<NuxtPage>exists or do you have valid use cases of that in mind? 🤔Repro: https://stackblitz.com/edit/nuxt-issues-25077?file=pages%2Findex.vue
bolt-new-by-stackblitz commentedon Jan 6, 2024
danielroe commentedon Jan 6, 2024
I think that would be a nice DX improvement. 👌
[-]Nested Dynamic Routes working improperly[/-][+]Warn if nested route without `<NuxtPage />` exists[/+][-]Warn if nested route without `<NuxtPage />` exists[/-][+]Warn in dev mode if nested route without `<NuxtPage />` exists[/+]saidinusah commentedon Jan 11, 2024
hi, is anyone working on this? I'd love to work on it
TheAlexLichter commentedon Jan 11, 2024
@1nusah go for it 👍
saidinusah commentedon Jan 11, 2024
heyy @manniL, is there a way to know if the parent route (same thing as the base route?) doesn't have the component? I'm looking at checking if a route has children and if it has the NuxtPage component. What do you think of this approach?
TheAlexLichter commentedon Jan 11, 2024
@1nusah maybe you could use a similar approach as for
<NuxtLayout>- see #24116saidinusah commentedon Jan 15, 2024
hi @manniL, I thought the best approach was to show devs when a route has children but the component isn't used in the base route/path but this won't work if you use the component in the app.vue file as it automatically works as if all other routes use this component. Another approach may be to just check if the user has multiple routes and doesn't use the component but this doesn't seem to greatly improve DX in any way to me. What do you think?
feat(nuxt): warn when parent page lacks NuxtPage
feat(nuxt): warn when parent page lacks NuxtPage
Jorgagu commentedon Jul 18, 2026
@TheAlexLichter @danielroe this issue will be resolved by #35639, could you please review ?