From d5929233384756e2726bf9dc6fc2c64f2098b0c7 Mon Sep 17 00:00:00 2001 From: Niklas Lausch Date: Tue, 17 Mar 2026 15:17:15 +0100 Subject: [PATCH 1/2] feat: ignoreGenerateWarning option --- src/module.ts | 22 +++++++++++++++------- src/types/config.ts | 1 + 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/module.ts b/src/module.ts index 0569a168d..0b5e60914 100644 --- a/src/module.ts +++ b/src/module.ts @@ -27,15 +27,9 @@ export default defineNuxtModule({ }, defaults: {}, async setup(options, nuxt) { - // Cannot be used with `nuxt generate` - if (nuxt.options.nitro.static || (nuxt.options as any)._generate) { - log.error('NuxtHub is not compatible with `nuxt generate` as it needs a server to run.') - log.info('To pre-render all pages: `https://hub.nuxt.com/docs/recipes/pre-rendering#pre-render-all-pages`') - return process.exit(1) - } - const rootDir = nuxt.options.rootDir const hosting = process.env.NITRO_PRESET || nuxt.options.nitro.preset || provider + const hub = defu(options, { // Local storage dir: '.data', @@ -49,6 +43,20 @@ export default defineNuxtModule({ // resolve the hub directory hub.dir = await resolveFs(nuxt.options.rootDir, hub.dir) + // Cannot be used with `nuxt generate` + if ( + !hub.ignoreGenerateWarning + && (nuxt.options.nitro.static || (nuxt.options as any)._generate) + ) { + log.error( + 'NuxtHub is not compatible with `nuxt generate` as it needs a server to run.' + ) + log.info( + 'To pre-render all pages: `https://hub.nuxt.com/docs/recipes/pre-rendering#pre-render-all-pages`' + ) + return process.exit(1) + } + // Create the hub directory await mkdir(hub.dir, { recursive: true }) .catch((e: any) => { diff --git a/src/types/config.ts b/src/types/config.ts index c0edaa201..a7df02444 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -11,6 +11,7 @@ export interface HubConfig { kv: boolean | KVConfig dir: string hosting: string + ignoreGenerateWarning: boolean } export interface ResolvedHubConfig extends HubConfig { From 4780c09f3af6ff0747275386ff1476c5be78481d Mon Sep 17 00:00:00 2001 From: Niklas Lausch Date: Tue, 17 Mar 2026 15:31:04 +0100 Subject: [PATCH 2/2] docs: added ignoreGenrateWarning option --- docs/content/docs/1.getting-started/2.installation.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/content/docs/1.getting-started/2.installation.md b/docs/content/docs/1.getting-started/2.installation.md index eb13e4863..a2fb5b4a2 100644 --- a/docs/content/docs/1.getting-started/2.installation.md +++ b/docs/content/docs/1.getting-started/2.installation.md @@ -82,6 +82,11 @@ export default defineNuxtConfig({ ::field{name="dir" type="string"} Default to `'.data'` - The directory used for storage (database, kv, cache, etc.) during local development. :: + + ::field{name="ignoreGenerateWarning" type="boolean"} + Default to `false` - When generating with `nuxi generate` the default behaviour is to exit with an error because NuxtHub is not designed for static hosting. + In certain scenarios it might be desirable to ignore this warning. + :: :: ::tip{icon="i-lucide-rocket"}