Nitro · storage

NITRO0034Mount storage before using a base in production

Report useStorage() and useKV() calls whose base no production storage mount covers, and record the mounts Nitro config declares as the nitroStorage Project Inventory fact.

Why it happens

unstorage sends a key to the longest matching mount, then falls back to the root mount, which defaults to an in-memory driver. A mount declared only in devStorage does not apply in production. Doctor checks Nitro 2 storage and bundledStorage, Nitro 3 kv (or its storage alias), and the built-in mounts for the detected version and preset. A parent base can list its mounted descendants, but a specific item key only uses a mount that covers that key. In a Nuxt app with a current Doctor manifest, Doctor reads the mounts Nitro resolved after every module and layer ran, so only a runtime plugin that mounts storage leaves a gap. Otherwise Doctor records an evidence gap and skips the check when unreadable config, a module or layer, or a runtime storage mount could change the production mount table.

Fix

Declare a production mount for the base under nitro.storage (Nitro 2 and Nuxt) or kv (Nitro 3), or move the keys to a base you already mount.

Example

Mount the base for production, not only dev

Before

// nuxt.config.ts
export default defineNuxtConfig({
  nitro: { devStorage: { sessions: { driver: 'fs', base: './.data/sessions' } } },
})

// server/api/session.get.ts
export default defineEventHandler(() => useStorage('sessions').getKeys())

After

// nuxt.config.ts
export default defineNuxtConfig({
  nitro: { storage: { sessions: { driver: 'redis', url: process.env.REDIS_URL } } },
})

// server/api/session.get.ts
export default defineEventHandler(() => useStorage('sessions').getKeys())

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --framework nitro --extends auto,nitro/strict --rules nitro/storage/no-undeclared-mount
Copyright © 2026