Nuxt · NUXT0109

Keep types shared by server and app in shared/types

Report type imports of app code in Nuxt server code, including inline `type` specifiers next to values that need no app API.
NUXT0109vite-doctor/nuxtarchitectureinfoSuggestion

Run this rule

pnpm nuxt doctor --extends auto,nuxt/strict --rules nuxt/structure/no-app-types-in-server

Why it matters

Type-only imports are erased from the server bundle, but they couple server code to app internals. A refactor that adds a runtime import next to the type pulls app code into the server. Types used by both sides belong in shared/types/, which Nuxt auto-imports in both the app and the server.

Move types used by both the server and the app to shared/types/ and import them from there on both sides.

Example

Share types through shared/types

Before

// server/api/cart.get.ts
import type { Cart } from '~/types/cart'

After

// shared/types/cart.ts
export interface Cart {
  items: string[]
}

// server/api/cart.get.ts: auto-imported
export default defineEventHandler((): Cart => ({ items: [] }))
Copyright © 2026