| Nuxt 5 production optimization: hydration, performance, testing with Vitest, deployment to Cloudflare/Vercel/Netlify, and migration from Nuxt 4. Use when: debugging hydration mismatches, optimizing performance and Core Web Vitals, writing tests with Vitest, deploying to Cloudflare Pages/Workers/Vercel/Netlify, or migrating from Nuxt 4 to Nuxt 5.
npx skills add https://github.com/secondsky/claude-skills --skill nuxt-production
Hydration, performance, testing, deployment, and migration patterns.
| Change | Nuxt 4 | Nuxt 5 |
|--------|--------|--------|
| Bundler | Vite 6 (esbuild + Rollup) | Vite 8 (Rolldown) |
| Server engine | Nitro v2 | Nitro v3 (h3 v2) |
| Server errors | createError({statusCode}) | HTTPError({status}) |
| Client-only placeholder | Empty <div> | HTML comment node |
| callHook | Always returns Promise | May return void |
| clearNuxtState | Sets to undefined | Resets to initial default |
| Page names | Auto-generated | Normalized to route names |
| JSX support | Included by default | Optional (on-demand) |
| externalVue | Configurable | Removed (always mocked) |
Client-only components (.client.vue files and createClientOnly() wrappers) now render an HTML comment on the server instead of an empty <div>. This fixes scoped styles hydration issues.
<!-- If you relied on the placeholder <div> for layout -->
<ClientOnly>
<MyComponent />
<template #fallback>
<div class="placeholder" style="min-height: 200px"></div>
</template>
</ClientOnly>
To revert to the old <div> behavior:
// nuxt.config.ts
export default defineNuxtConfig({
experimental: {
clientNodePlaceholder: false
}
})
callHook may now return void instead of always returning Promise. Always use await:
// WRONG
nuxtApp.callHook('my:hook', data).then(() => { ... })
// CORRECT
await nuxtApp.callHook('my:hook', data)
Load references/hydration.md when:
Load references/performance.md when:
Load references/testing-vitest.md when:
Load references/deployment-cloudflare.md when:
| Cause | Example | Fix |
|-------|---------|-----|
| Non-deterministic values | Math.random() | Use useState |
| Browser APIs on server | window.innerWidth | Use onMounted |
| Date/time on server | new Date() | Use useState or ClientOnly |
| Third-party scripts | Analytics | Use ClientOnly |
<!-- Non-deterministic values -->
<script setup>
const id = useState('random-id', () => Math.random())
</script>
<!-- Browser APIs -->
<script setup>
const width = ref(0)
onMounted(() => {
width.value = window.innerWidth
})
</script>
<!-- ClientOnly component -->
<template>
<ClientOnly>
<MyMapComponent />
<template #fallback>
<div class="skeleton">Loading map...</div>
</template>
</ClientOnly>
</template>
<script setup>
const HeavyChart = defineAsyncComponent(() =>
import('~/components/HeavyChart.vue')
)
</script>
<script setup>
const LazyComponent = defineLazyHydrationComponent(
'visible',
() => import('./HeavyComponent.vue')
)
const InteractiveComponent = defineLazyHydrationComponent(
'interaction',
() => import('./InteractiveComponent.vue')
)
const IdleComponent = defineLazyHydrationComponent(
'idle',
() => import('./IdleComponent.vue')
)
</script>
export default defineNuxtConfig({
routeRules: {
'/': { prerender: true },
'/about': { prerender: true },
'/blog/**': { swr: 3600 },
'/products/**': { isr: 3600 },
'/dashboard/**': { ssr: false },
'/static/**': {
headers: { 'Cache-Control': 'public, max-age=31536000' }
}
}
})
<template>
<NuxtImg
src="/images/hero.jpg"
alt="Hero image"
width="800"
height="400"
loading="lazy"
placeholder
format="webp"
/>
<NuxtPicture
src="/images/product.jpg"
alt="Product"
sizes="sm:100vw md:50vw lg:400px"
:modifiers="{ quality: 80 }"
/>
</template>
bun add -d @nuxt/test-utils vitest @vue/test-utils happy-dom
// vitest.config.ts
import { defineVitestConfig } from '@nuxt/test-utils/config'
export default defineVitestConfig({
test: {
environment: 'nuxt',
environmentOptions: {
nuxt: {
domEnvironment: 'happy-dom'
}
}
}
})
import { describe, it, expect } from 'vitest'
import { mountSuspended } from '@nuxt/test-utils/runtime'
import UserCard from '~/components/UserCard.vue'
describe('UserCard', () => {
it('renders user name', async () => {
const wrapper = await mountSuspended(UserCard, {
props: {
user: { id: 1, name: 'John Doe', email: '[email protected]' }
}
})
expect(wrapper.text()).toContain('John Doe')
})
})
import { mockNuxtImport } from '@nuxt/test-utils/runtime'
mockNuxtImport('useFetch', () => {
return () => ({
data: ref({ users: [{ id: 1, name: 'John' }] }),
pending: ref(false),
error: ref(null)
})
})
bun run build
bunx wrangler pages deploy .output/public
export default defineNuxtConfig({
nitro: { preset: 'cloudflare_pages' }
})
export default defineNuxtConfig({
nitro: { preset: 'cloudflare_module' }
})
// Vercel
export default defineNuxtConfig({
nitro: { preset: 'vercel' }
})
// Netlify
export default defineNuxtConfig({
nitro: { preset: 'netlify' }
})
bun add @nuxthub/core
export default defineNuxtConfig({
modules: ['@nuxthub/core'],
hub: {
database: true,
kv: true,
blob: true,
cache: true
}
})
{
"devDependencies": {
"nuxt": "^5.0.0"
}
}
// nuxt.config.ts
export default defineNuxtConfig({
future: {
compatibilityVersion: 5
}
})
// Before (Nuxt 4)
import { createError } from 'h3'
throw createError({ statusCode: 404, statusMessage: 'Not Found' })
// After (Nuxt 5)
import { HTTPError } from 'nitro/h3'
throw new HTTPError({ status: 404, statusText: 'Not Found' })
// Before (Nuxt 4)
const path = event.path
event.node.res.statusCode = 200
setResponseHeader(event, 'x-custom', 'value')
const config = useRuntimeConfig(event)
// After (Nuxt 5)
const path = event.url.pathname
event.res.status = 200
event.res.headers.set('x-custom', 'value')
const config = useRuntimeConfig()
// Before (Nuxt 4)
export default defineNuxtConfig({
vite: {
build: {
rollupOptions: { ... }
}
}
})
// After (Nuxt 5) - use rolldownOptions
export default defineNuxtConfig({
vite: {
build: {
rolldownOptions: { ... }
}
}
})
// Before
routeRules: {
'/old': { redirect: { to: '/new', statusCode: 302 } }
}
// After
routeRules: {
'/old': { redirect: { to: '/new', status: 302 } }
}
// Before
import { defineEventHandler, getQuery } from 'h3'
// After
import { defineEventHandler, getQuery } from 'nitro/h3'
// Or rely on auto-imports (no import needed)
// Remove these from nuxt.config.ts
export default defineNuxtConfig({
experimental: {
externalVue: false, // REMOVED - delete this
viteEnvironmentApi: true, // REMOVED - always enabled
}
})
# Only if your project uses .jsx/.tsx files
bun add -D @vitejs/plugin-vue-jsx
// Before
nuxtApp.callHook('my:hook', data).then(() => { ... })
// After
await nuxtApp.callHook('my:hook', data)
// WRONG
const width = window.innerWidth
// CORRECT
if (import.meta.client) {
const width = window.innerWidth
}
// Or use onMounted
onMounted(() => {
const width = window.innerWidth
})
// WRONG
const id = Math.random()
const time = Date.now()
// CORRECT
const id = useState('id', () => Math.random())
const time = useState('time', () => Date.now())
Hydration Mismatch:
window, document, localStorage usageClientOnly or use onMountedMath.random(), Date.now()<div> placeholder for client-only componentsBuild Errors:
rm -rf .nuxt .output node_modules/.vite && bun install
Vite Plugin Warnings:
extendViteConfig({ server }) to configEnvironmentapplyToEnvironment instead of server: false / client: falseRolldown Build Issues:
rollupOptions with rolldownOptionsvite.esbuild with vite.oxcVersion: 5.0.0 | Last Updated: 2026-03-30 | License: MIT
Comprehensive healthcare AI toolkit for developing, testing, and deploying machine learning models with clinical data. This skill should be used when working with electronic health records (EHR), clinical prediction tasks (mortality, readmission, drug recommendation), medical coding systems (ICD, NDC, ATC), physiological signals (EEG, ECG), healthcare datasets (MIMIC-III/IV, eICU, OMOP), or implementing deep learning models for healthcare applications (RETAIN, SafeDrug, Transformer, GNN).
Comprehensive healthcare AI toolkit for developing, testing, and deploying machine learning models with clinical data. This skill should be used when working with electronic health records (EHR), clinical prediction tasks (mortality, readmission, drug recommendation), medical coding systems (ICD, NDC, ATC), physiological signals (EEG, ECG), healthcare datasets (MIMIC-III/IV, eICU, OMOP), or implementing deep learning models for healthcare applications (RETAIN, SafeDrug, Transformer, GNN).
Expert performance engineer specializing in modern observability, application optimization, and scalable system performance. Masters OpenTelemetry, distributed tracing, load testing, multi-tier caching, Core Web Vitals, and performance monitoring. Handles end-to-end optimization, real user monitoring, and scalability patterns. Use PROACTIVELY for performance optimization, observability, or scalability challenges.
Master AI-powered test automation with modern frameworks, self-healing tests, and comprehensive quality engineering. Build scalable testing strategies with advanced CI/CD integration. Use PROACTIVELY for testing automation or quality assurance.
Internet Court adapter for GenLayer Intelligent Contract supervision. Use to specify agent-performance rubrics, evidence schemas, decision outputs, and ERC-7710 connector expectations, while delegating actual GenLayer contract writing, linting, testing, deployment, and CLI interaction to the official GenLayer skills at https://skills.genlayer.com/.
> Suggests using Microsoft Testing Platform (MTP) hot reload to iterate fixes on failing tests without rebuilding. Use when user says "hot reload tests", "iterate on test fix", "run tests without rebuilding", "speed up test loop", "fix test faster", or needs to set up MTP hot reload to rapidly iterate on test failures. Covers setup (NuGet package, environment variable, launchSettings.json) and the iterative workflow for fixing tests. normally with dotnet test (use run-tests), applying test filters, producing TRX reports, CI/CD pipeline configuration, or Visual Studio Test Explorer hot reload (which is a different feature).
Build production Apache Airflow DAGs with best practices for operators, sensors, testing, and deployment. Use when creating data pipelines, orchestrating workflows, or scheduling batch jobs.
Build production-grade Azure Cosmos DB NoSQL services following clean code, security best practices, and TDD principles.
Take secondsky/nuxt-production from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.