Debug Nuxt.js issues systematically: SSR errors, Nitro server problems, hydration mismatches, composable issues with useFetch/useAsyncData, plugin failures, module conflicts, and auto-import problems.
Ships in debug-and-refactor. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
This guide provides a systematic approach to debugging Nuxt.js applications, covering SSR/SSG issues, Nitro server problems, hydration mismatches, composables, and more.
Hydration mismatches occur when the server-rendered HTML differs from what Vue expects on the client.
Symptoms:
[Vue warn]: Hydration completed but contains mismatchesCommon Causes:
// BAD: Using browser-only APIs during SSR
const windowWidth = window.innerWidth // Errors on server
// GOOD: Guard with process.client or useNuxtApp()
const windowWidth = ref(0)
onMounted(() => {
windowWidth.value = window.innerWidth
})
// GOOD: Use ClientOnly component
<ClientOnly>
<BrowserOnlyComponent />
</ClientOnly>
// BAD: Date/time rendering inconsistency
<span>{{ new Date().toLocaleString() }}</span> // Different on server vs client
// GOOD: Use consistent formatting or client-only
<ClientOnly>
<span>{{ formattedDate }}</span>
<template #fallback>Loading...</template>
</ClientOnly>
Debugging Steps:
window, document, localStorage usage outside onMounted or process.clientCommon Issues:
// ERROR: "useFetch is not defined" or composable called outside setup
// BAD: Calling in regular function
function fetchData() {
const { data } = useFetch('/api/data') // Error!
}
// GOOD: Call in setup or use $fetch in functions
const { data, error, pending, refresh } = useFetch('/api/data')
// Or for functions:
async function fetchData() {
const data = await $fetch('/api/data')
}
Key/Caching Issues:
// BAD: Same key returns cached data
const { data: user1 } = useFetch('/api/user', { key: 'user' })
const { data: user2 } = useFetch('/api/user', { key: 'user' }) // Returns same cached data!
// GOOD: Use unique keys
const { data: user1 } = useFetch('/api/user/1', { key: 'user-1' })
const { data: user2 } = useFetch('/api/user/2', { key: 'user-2' })
// Force refresh
const { data, refresh } = useFetch('/api/data')
await refresh() // Bypasses cache
Watch for Reactive Parameters:
// BAD: Non-reactive parameter won't trigger refetch
const userId = '123'
const { data } = useFetch(`/api/user/${userId}`)
// GOOD: Use computed or getter for reactive URLs
const userId = ref('123')
const { data } = useFetch(() => `/api/user/${userId.value}`)
// Or with watch
const { data } = useFetch('/api/user', {
query: { id: userId },
watch: [userId]
})
500 Internal Server Errors:
// Check server/api/ files for issues
// server/api/example.ts
// BAD: Unhandled errors crash the endpoint
export default defineEventHandler(async (event) => {
const data = await fetchExternalAPI() // Unhandled rejection
return data
})
// GOOD: Proper error handling
export default defineEventHandler(async (event) => {
try {
const data = await fetchExternalAPI()
return data
} catch (error) {
throw createError({
statusCode: 500,
statusMessage: 'Failed to fetch data',
data: { originalError: error.message }
})
}
})
Reading Request Body:
// BAD: Wrong method to read body
export default defineEventHandler(async (event) => {
const body = event.body // undefined!
// GOOD: Use readBody
const body = await readBody(event)
// For query params
const query = getQuery(event)
// For route params
const { id } = event.context.params
})
// plugins/my-plugin.ts
// BAD: Plugin errors break the entire app
export default defineNuxtPlugin(() => {
const api = new ExternalAPI() // May throw
})
// GOOD: Error handling in plugins
export default defineNuxtPlugin({
name: 'my-plugin',
enforce: 'pre', // or 'post'
async setup(nuxtApp) {
try {
const api = new ExternalAPI()
return {
provide: {
api
}
}
} catch (error) {
console.error('Plugin initialization failed:', error)
// Provide fallback or skip
}
}
})
// Client-only plugin
export default defineNuxtPlugin({
name: 'client-only-plugin',
setup() {
// This only runs on client
}
})
// Name file: plugins/my-plugin.client.ts
Diagnosing Module Issues:
// nuxt.config.ts
export default defineNuxtConfig({
modules: [
'@nuxtjs/tailwindcss',
'@pinia/nuxt',
// Module order can matter!
],
// Debug module loading
debug: true, // Shows module loading in console
})
Common Module Conflicts:
# Clear module cache
rm -rf node_modules/.cache
rm -rf .nuxt
# Reinstall dependencies
rm -rf node_modules
npm install
// nuxt.config.ts
export default defineNuxtConfig({
devtools: { enabled: true }
})
Features:
Access: Press Shift + Alt + D or click floating icon in dev mode
// nuxt.config.ts
export default defineNuxtConfig({
sourcemap: {
server: true,
client: true
}
})
Create .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"type": "chrome",
"request": "launch",
"name": "Debug Nuxt Client",
"url": "http://localhost:3000",
"webRoot": "${workspaceFolder}"
},
{
"type": "node",
"request": "launch",
"name": "Debug Nuxt Server",
"program": "${workspaceFolder}/node_modules/nuxi/bin/nuxi.mjs",
"args": ["dev"],
"cwd": "${workspaceFolder}"
}
]
}
# Start with debugger
nuxi dev --inspect
# Or with specific host for Docker
nuxi dev --inspect=0.0.0.0
// Runs on both server and client
console.log('Universal log')
// Server-only logging
if (process.server) {
console.log('Server-side only')
}
// Client-only logging
if (process.client) {
console.log('Client-side only')
}
// In composables
const nuxtApp = useNuxtApp()
if (nuxtApp.ssrContext) {
console.log('Server-side render')
}
# Install Vue DevTools browser extension
# Or use standalone
npx @vue/devtools
Determine where the error occurs:
// Check execution context
console.log('Server:', process.server)
console.log('Client:', process.client)
console.log('Dev:', process.dev)
console.log('SSR:', !!useNuxtApp().ssrContext)
Questions to answer:
<template>
<div>
<!-- Wrap suspect components -->
<NuxtErrorBoundary @error="logError">
<SuspectComponent />
<template #error="{ error }">
<p>Error: {{ error.message }}</p>
</template>
</NuxtErrorBoundary>
</div>
</template>
<script setup>
function logError(error) {
console.error('Caught error:', error)
}
</script>
// Debug useFetch/useAsyncData
const { data, error, pending, status } = useFetch('/api/data')
watch([data, error, pending], ([d, e, p]) => {
console.log('Data:', d)
console.log('Error:', e)
console.log('Pending:', p)
})
// Check payload (what's sent from server to client)
const nuxtApp = useNuxtApp()
console.log('Payload:', nuxtApp.payload)
# Type check
nuxi typecheck
# Analyze bundle
nuxi analyze
# Clean build
rm -rf .nuxt .output node_modules/.cache
nuxi build
# Start dev server
nuxi dev
# Start with debugging
nuxi dev --inspect
# Start on specific port
nuxi dev --port 3001
# Start with HTTPS
nuxi dev --https
# Production build
nuxi build
# Generate static site
nuxi generate
# Preview production build
nuxi preview
# Analyze bundle size
nuxi analyze
# Type checking
nuxi typecheck
# Prepare Nuxt (generate types)
nuxi prepare
# Clean Nuxt files
nuxi cleanup
# Upgrade Nuxt
nuxi upgrade
# Add module
nuxi module add @nuxtjs/tailwindcss
# Create new component/page/etc
nuxi add component MyComponent
nuxi add page about
nuxi add composable useMyComposable
nuxi add api hello
// plugins/error-handler.ts
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.config.errorHandler = (error, instance, info) => {
console.error('Vue Error:', error)
console.error('Component:', instance)
console.error('Info:', info)
}
nuxtApp.hook('vue:error', (error, instance, info) => {
console.error('Nuxt Vue Error Hook:', error)
})
nuxtApp.hook('app:error', (error) => {
console.error('App Error:', error)
})
})
<!-- error.vue (in root, NOT in pages/) -->
<template>
<div class="error-page">
<h1>{{ error.statusCode }}</h1>
<p>{{ error.message }}</p>
<button @click="handleError">Go Home</button>
</div>
</template>
<script setup>
const props = defineProps({
error: Object
})
const handleError = () => clearError({ redirect: '/' })
</script>
// Throw errors
throw createError({
statusCode: 404,
statusMessage: 'Page not found',
fatal: true // Triggers error page
})
// Show error without navigation
showError({
statusCode: 500,
statusMessage: 'Something went wrong'
})
// Clear error
clearError({ redirect: '/' })
// Access current error
const error = useError()
<template>
<NuxtErrorBoundary>
<RiskyComponent />
<template #error="{ error, clearError }">
<div class="error-box">
<p>Component failed: {{ error.message }}</p>
<button @click="clearError">Retry</button>
</div>
</template>
</NuxtErrorBoundary>
</template>
// Debug what's in the payload
const nuxtApp = useNuxtApp()
onMounted(() => {
console.log('SSR Payload:', nuxtApp.payload)
console.log('SSR Data:', nuxtApp.payload.data)
console.log('SSR State:', nuxtApp.payload.state)
})
// Ensure data is awaited properly
const { data } = await useFetch('/api/data')
// For lazy loading (doesn't block navigation)
const { data, pending } = useLazyFetch('/api/data')
// Watch for data availability
watch(data, (newData) => {
if (newData) {
console.log('Data loaded:', newData)
}
})
// Use server utilities correctly
// server/utils/db.ts - only available in server/
// For runtime config (secrets)
// nuxt.config.ts
export default defineNuxtConfig({
runtimeConfig: {
apiSecret: '', // Server-only
public: {
apiBase: '' // Exposed to client
}
}
})
// Usage
const config = useRuntimeConfig()
// config.apiSecret - only on server
// config.public.apiBase - available everywhere
// nuxt.config.ts
export default defineNuxtConfig({
experimental: {
componentIslands: true // For heavy components
}
})
<!-- Use islands for heavy server components -->
<NuxtIsland name="HeavyChart" :props="{ data: chartData }" />
// Lazy load components
const HeavyComponent = defineAsyncComponent(() =>
import('~/components/HeavyComponent.vue')
)
// Or use Nuxt's auto-import with Lazy prefix
<template>
<LazyHeavyComponent v-if="showHeavy" />
</template>
# Generate bundle analysis
nuxi analyze
# Check what's in your bundle
cat .output/public/_nuxt/builds/meta/*.json | jq
// BAD
function handleClick() {
const route = useRoute() // Error!
}
// GOOD
const route = useRoute()
function handleClick() {
console.log(route.path)
}
// BAD: Non-reactive
const id = '123'
useFetch(`/api/items/${id}`)
// GOOD: Reactive
const id = ref('123')
useFetch(() => `/api/items/${id.value}`)
// Prefer navigateTo over useRouter for navigation
await navigateTo('/dashboard')
await navigateTo({ path: '/user', query: { id: 1 } })
// For programmatic redirects in server
export default defineEventHandler((event) => {
return sendRedirect(event, '/login', 302)
})
// Named middleware runs in alphabetical order
// middleware/01.auth.global.ts runs before middleware/02.analytics.global.ts
// Route-specific middleware
definePageMeta({
middleware: ['auth', 'premium'] // Runs in order
})
// BAD: Shared state between requests
const globalState = reactive({})
// GOOD: Use useState for SSR-safe state
const state = useState('key', () => ({}))
// Or Pinia with proper SSR setup
const store = useMyStore()
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
45 skills in this plugin
/debug:angularDebug Angular applications systematically with expert-level diagnostic techniques. This skill provides comprehensive guidance for troubleshooting dependency injection errors, change detection issues (NG0100), RxJS subscription leaks, lazy loading failures, zone.js problems, and common Angular runtime errors. Includes structured four-phase debugging methodology, Angular DevTools usage, console debugging utilities (ng.probe), and performance profiling strategies for modern Angular applications./debug:djangoDebug Django web applications with systematic diagnostic approaches. This skill covers troubleshooting Django-specific errors including TemplateDoesNotExist, ImproperlyConfigured, IntegrityError, migration conflicts, CSRF failures, N+1 query problems, and circular imports. Includes Django Debug Toolbar setup, ORM query logging, pdb/ipdb usage, shell_plus debugging, and comprehensive logging configuration. Provides four-phase methodology for root cause analysis and regression prevention.Other plugins' skills for the same job
/debug:dockerDebug Docker containers, images, and infrastructure with systematic diagnostic techniques. This skill provides comprehensive guidance for troubleshooting container exit codes, OOM kills, image build failures, networking issues, volume mount problems, and permission errors. Covers four-phase debugging methodology from quick assessment to deep analysis, essential Docker commands, debug container techniques for minimal images, and platform-specific troubleshooting for Windows, Mac, and Linux./debug-and-refactor:debug:nuxtjsfrom debug-and-refactor
npx claudepluginhub snakeo/claude-debug-and-refactor-skills-plugin --plugin debug-and-refactor