Nuxt · Architecture

NUXT0075Do not import server code into app or shared code

Report runtime imports from the Nuxt server directory in app or shared code.

Why it happens

Nuxt's import protection doesn't block server/utils. Importing from it in app code ships server code (database clients, private config reads, Node APIs) into the client bundle. Code used by both sides belongs in shared/utils/, which Nuxt auto-imports in both the app and the server.

Fix

Move code used by both the app and the server to shared/utils/. Keep server-only logic in server/ and call it through an API route.

Example

Share utilities through shared/utils

Before

// app/components/PriceTag.vue <script setup>
import { formatPrice } from '~~/server/utils/pricing'

After

// shared/utils/format-price.ts
export function formatPrice(cents: number, currency: string) {
  return new Intl.NumberFormat('en', { style: 'currency', currency }).format(cents / 100)
}

// app/components/PriceTag.vue: auto-imported
const label = computed(() => formatPrice(props.cents, props.currency))

Verify the fix

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

pnpm nuxt doctor --rules nuxt/structure/no-server-utils-in-app
Copyright © 2026