#Organized page structure
3 messages · Page 1 of 1 (latest)
Hi @silk pulsar. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
To achieve a custom page structure like app/auth/pages/login.vue and app/auth/pages/register.vue with Nuxt v4 compatibility, you need to tell Nuxt to look for pages in non-default locations, since by default it expects all pages to be under app/pages/ (or pages/ at the root, depending on your configuration).
Nuxt provides a pages option in nuxt.config.ts where you can specify a glob pattern or an array of patterns to scan for page files. For your structure, you should set the pattern to include your custom path:
// nuxt.config.ts
export default defineNuxtConfig({
pages: {
pattern: ['auth/pages/**/*.vue'],
}
})
This tells Nuxt to treat all .vue files under app/auth/pages/ as pages and generate routes for them. Make sure that your srcDir is set to app (which is the default in v4 compatibility mode), or adjust the pattern accordingly if your structure is different Docs: pages config.
Key points:
- Use the
pages.patternoption to specify custom locations for your page files. - The default behavior only scans
app/pages/(orpages/at the root), so you must override it for custom structures. - This feature is available in Nuxt v4 compatibility mode and later GitHub PR: glob patterns for pages.
If you have other folders with pages, you can add more patterns to the array.
Example:
export default defineNuxtConfig({
pages: {
pattern: [
'auth/pages/**/*.vue',
'other/pages/**/*.vue'
],
}
})