Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Nuxt 3.x reference covering SSR, file-based routing, auto-imports, server routes, and Nitro deployment.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/features-components.md
1---2name: built-in-components3description: NuxtLink, NuxtPage, NuxtLayout, and other built-in Nuxt components4---56# Built-in Components78Nuxt provides several built-in components for common functionality.910## NuxtLink1112Optimized link component with prefetching:1314```vue15<template>16<!-- Basic usage -->17<NuxtLink to="/about">About</NuxtLink>1819<!-- With route object -->20<NuxtLink :to="{ name: 'posts-id', params: { id: 1 } }">Post 1</NuxtLink>2122<!-- External link (opens in new tab) -->23<NuxtLink to="https://nuxt.com" external>Nuxt</NuxtLink>2425<!-- Disable prefetching -->26<NuxtLink to="/heavy-page" :prefetch="false">Heavy Page</NuxtLink>2728<!-- Replace history instead of push -->29<NuxtLink to="/page" replace>Replace</NuxtLink>3031<!-- Custom active class -->32<NuxtLink33to="/dashboard"34active-class="text-primary"35exact-active-class="font-bold"36>37Dashboard38</NuxtLink>39</template>40```4142## NuxtPage4344Renders the current page component (used in layouts):4546```vue47<!-- app/app.vue -->48<template>49<NuxtLayout>50<NuxtPage />51</NuxtLayout>52</template>53```5455With page transitions:5657```vue58<template>59<NuxtPage :transition="{ name: 'fade', mode: 'out-in' }" />60</template>61```6263Pass props to page:6465```vue66<template>67<NuxtPage :page-key="route.fullPath" :foobar="123" />68</template>69```7071## NuxtLayout7273Controls layout rendering:7475```vue76<!-- app/app.vue -->77<template>78<NuxtLayout>79<NuxtPage />80</NuxtLayout>81</template>82```8384Dynamic layout:8586```vue87<template>88<NuxtLayout :name="layout">89<NuxtPage />90</NuxtLayout>91</template>9293<script setup>94const layout = computed(() => isAdmin ? 'admin' : 'default')95</script>96```9798Layout with transitions:99100```vue101<template>102<NuxtLayout :transition="{ name: 'slide', mode: 'out-in' }">103<NuxtPage />104</NuxtLayout>105</template>106```107108## NuxtLoadingIndicator109110Progress bar for page navigation:111112```vue113<!-- app/app.vue -->114<template>115<NuxtLoadingIndicator116color="repeating-linear-gradient(to right, #00dc82 0%, #34cdfe 50%, #0047e1 100%)"117:height="3"118:duration="2000"119:throttle="200"120/>121<NuxtLayout>122<NuxtPage />123</NuxtLayout>124</template>125```126127## NuxtErrorBoundary128129Catch and handle errors in child components:130131```vue132<template>133<NuxtErrorBoundary @error="handleError">134<ComponentThatMightFail />135136<template #error="{ error, clearError }">137<div class="error">138<p>Something went wrong: {{ error.message }}</p>139<button @click="clearError">Try again</button>140</div>141</template>142</NuxtErrorBoundary>143</template>144145<script setup>146function handleError(error) {147console.error('Error caught:', error)148}149</script>150```151152## ClientOnly153154Render content only on client-side:155156```vue157<template>158<ClientOnly>159<!-- Browser-only component -->160<BrowserOnlyChart :data="chartData" />161162<template #fallback>163<p>Loading chart...</p>164</template>165</ClientOnly>166</template>167```168169## DevOnly170171Render content only in development:172173```vue174<template>175<DevOnly>176<DebugPanel />177</DevOnly>178</template>179```180181## NuxtIsland182183Server components (experimental):184185```vue186<template>187<NuxtIsland name="HeavyComponent" :props="{ data: complexData }" />188</template>189```190191Islands render in their own isolated Vue app keyed on props (for cacheability). `useRoute()` and other vue-router composables inside an island reflect the island's own request, **not** the current page — pass route info in via props or the `context` prop. Props/context are sent as GET query params (may appear in logs/CDN caches).192193## NuxtImg and NuxtPicture194195Optimized images (requires `@nuxt/image` module):196197```vue198<template>199<!-- Basic optimized image -->200<NuxtImg src="/images/hero.jpg" width="800" height="600" />201202<!-- Responsive with srcset -->203<NuxtImg204src="/images/hero.jpg"205sizes="sm:100vw md:50vw lg:400px"206:modifiers="{ format: 'webp' }"207/>208209<!-- Art direction with picture -->210<NuxtPicture211src="/images/hero.jpg"212:img-attrs="{ alt: 'Hero image' }"213/>214</template>215```216217## Teleport218219Render content outside component tree:220221```vue222<template>223<button @click="showModal = true">Open Modal</button>224225<Teleport to="body">226<div v-if="showModal" class="modal">227<p>Modal content</p>228<button @click="showModal = false">Close</button>229</div>230</Teleport>231</template>232```233234For SSR, use `<ClientOnly>` with Teleport:235236```vue237<template>238<ClientOnly>239<Teleport to="#teleports">240<Modal />241</Teleport>242</ClientOnly>243</template>244```245246## NuxtRouteAnnouncer247248Accessibility: automatically announces page changes (from the page `<title>`) to screen readers:249250```vue251<!-- app/app.vue -->252<template>253<NuxtRouteAnnouncer />254<NuxtLayout>255<NuxtPage />256</NuxtLayout>257</template>258```259260## NuxtAnnouncer261262Accessibility: a hidden live region for **manual** announcements of dynamic content (form validation, toasts, loading). Add it once, then drive it with the `useAnnouncer` composable (Nuxt 4.4.2+):263264```vue265<!-- app/app.vue -->266<template>267<NuxtAnnouncer />268<NuxtLayout>269<NuxtPage />270</NuxtLayout>271</template>272```273274```vue275<script setup lang="ts">276const { polite, assertive } = useAnnouncer()277assertive('Error: form is invalid') // interrupts immediately278</script>279```280281Props: `politeness` (`polite` | `assertive` | `off`, default `polite`), `atomic` (default `true`). Use `<NuxtRouteAnnouncer>` for route changes, `<NuxtAnnouncer>` for everything else.282283<!--284Source references:285- https://nuxt.com/docs/4.x/api/components/nuxt-link286- https://nuxt.com/docs/4.x/api/components/nuxt-page287- https://nuxt.com/docs/4.x/api/components/nuxt-layout288- https://nuxt.com/docs/4.x/api/components/client-only289- https://nuxt.com/docs/4.x/api/components/nuxt-announcer290- https://nuxt.com/docs/4.x/api/components/nuxt-island291-->292