diff --git a/packages/nuxt3/src/pages/module.ts b/packages/nuxt3/src/pages/module.ts index ab7ef47d73..950eab2063 100644 --- a/packages/nuxt3/src/pages/module.ts +++ b/packages/nuxt3/src/pages/module.ts @@ -9,15 +9,15 @@ import { TransformMacroPlugin, TransformMacroPluginOptions } from './macros' export default defineNuxtModule({ meta: { - name: 'router' + name: 'pages' }, setup (_options, nuxt) { const pagesDirs = nuxt.options._layers.map( layer => resolve(layer.config.srcDir, layer.config.dir?.pages || 'pages') ) - // Disable module (and use universal router) if pages dir do not exists - if (!pagesDirs.some(dir => existsSync(dir))) { + // Disable module (and use universal router) if pages dir do not exists or user has disabled it + if (nuxt.options.pages === false || (nuxt.options.pages !== true && !pagesDirs.some(dir => existsSync(dir)))) { addPlugin(resolve(distDir, 'app/plugins/router')) return } diff --git a/packages/schema/src/config/_adhoc.ts b/packages/schema/src/config/_adhoc.ts index f58fee8b65..130e77a04b 100644 --- a/packages/schema/src/config/_adhoc.ts +++ b/packages/schema/src/config/_adhoc.ts @@ -35,4 +35,13 @@ export default { global: false, dirs: [] }, + + /** + * Whether to use the vue-router integration in Nuxt 3. If you do not provide a value it will be + * enabled if you have a `pages/` directory in your source folder. + * + * @type {boolean} + * @version 3 + */ + pages: undefined }