Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Nuxt 4+ development patterns: server routes, file-based routing, middleware, composables, and h3 v1 / nitropack v2.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/nuxt-components.md
1# Nuxt Built-in Components23## When to Use45Working with images, links, or time display in templates. **Always prefer Nuxt components over HTML elements.**67## Component Preferences89| HTML Element | Nuxt Component | Why |10| ------------ | -------------- | -------------------------------------- |11| `<a>` | `<NuxtLink>` | Client-side navigation, prefetching |12| `<img>` | `<NuxtImg>` | Optimization, lazy loading, responsive |13| `<time>` | `<NuxtTime>` | SSR-safe formatting, localization |1415## NuxtLink1617**ALWAYS use `<NuxtLink>` instead of `<a>` for internal links:**1819```vue20<template>21<!-- Internal navigation -->22<NuxtLink to="/about">About</NuxtLink>23<NuxtLink :to="{ name: '/users/[userId]', params: { userId } }">Profile</NuxtLink>2425<!-- External links (uses target="_blank" automatically with external) -->26<NuxtLink to="https://nuxt.com" external>Nuxt Docs</NuxtLink>2728<!-- Prefetch control -->29<NuxtLink to="/dashboard" :prefetch="false">Dashboard</NuxtLink>3031<!-- Active state styling -->32<NuxtLink to="/settings" active-class="text-primary" exact-active-class="font-bold">33Settings34</NuxtLink>35</template>36```3738**Props:**3940- `to` - Route path or route object41- `external` - Force external link behavior42- `target` - Link target (`_blank`, etc.)43- `prefetch` - Enable/disable prefetching (default: true)44- `noPrefetch` - Disable prefetching45- `activeClass` - Class when route matches46- `exactActiveClass` - Class when route exactly matches4748**Docs:** https://nuxt.com/docs/api/components/nuxt-link4950## NuxtImg5152**ALWAYS use `<NuxtImg>` instead of `<img>` for images:**5354Requires `@nuxt/image` module (usually pre-installed).5556```vue57<template>58<!-- Basic usage -->59<NuxtImg src="/images/hero.jpg" alt="Hero image" />6061<!-- Responsive with sizes -->62<NuxtImg63src="/images/banner.jpg"64alt="Banner"65width="1200"66height="600"67sizes="100vw sm:50vw md:400px"68/>6970<!-- Lazy loading (default) -->71<NuxtImg src="/images/photo.jpg" loading="lazy" alt="Photo" />7273<!-- Eager loading for above-fold -->74<NuxtImg src="/images/logo.svg" loading="eager" alt="Logo" />7576<!-- With placeholder blur -->77<NuxtImg src="/images/product.jpg" placeholder alt="Product" />7879<!-- Provider-specific (Cloudinary, etc.) -->80<NuxtImg provider="cloudinary" src="/folder/image.jpg" width="500" />8182<!-- Format conversion -->83<NuxtImg src="/images/photo.png" format="webp" alt="Photo" />84</template>85```8687**Props:**8889- `src` - Image source path90- `alt` - Alt text (required for accessibility)91- `width` / `height` - Dimensions92- `sizes` - Responsive sizes93- `loading` - `lazy` (default) or `eager`94- `placeholder` - Show blur placeholder while loading95- `format` - Force output format (`webp`, `avif`, etc.)96- `quality` - Image quality (1-100)97- `provider` - Image provider (cloudinary, imgix, etc.)9899**For art direction, use `<NuxtPicture>` (different sources per breakpoint).**100101**Docs:** https://image.nuxt.com/usage/nuxt-img102103## NuxtTime104105**ALWAYS use `<NuxtTime>` instead of `<time>` or manual formatting:**106107```vue108<template>109<!-- Relative time -->110<NuxtTime :datetime="post.createdAt" relative />111<!-- Output: "2 hours ago" -->112113<!-- Absolute with locale -->114<NuxtTime :datetime="event.date" locale="en-US" />115116<!-- Custom format -->117<NuxtTime :datetime="date" year="numeric" month="long" day="numeric" />118<!-- Output: "December 6, 2025" -->119120<!-- Short format -->121<NuxtTime :datetime="date" month="short" day="numeric" />122<!-- Output: "Dec 6" -->123124<!-- With time -->125<NuxtTime :datetime="date" hour="numeric" minute="2-digit" />126</template>127```128129**Props:**130131- `datetime` - Date string, Date object, or timestamp132- `relative` - Show relative time ("2 hours ago")133- `locale` - Locale for formatting134- `year`, `month`, `day`, `hour`, `minute`, `second` - Intl.DateTimeFormat options135136**Docs:** https://nuxt.com/docs/api/components/nuxt-time137138## Common Mistakes139140| ❌ Wrong | ✅ Right |141| ------------------------------------- | ---------------------------------------- |142| `<a href="/about">` | `<NuxtLink to="/about">` |143| `<img src="/photo.jpg">` | `<NuxtImg src="/photo.jpg" alt="...">` |144| `<time>{{ formatDate(date) }}</time>` | `<NuxtTime :datetime="date" />` |145| `formatTimeAgo(date)` in template | `<NuxtTime :datetime="date" relative />` |146| `new Date().toLocaleDateString()` | `<NuxtTime :datetime="date" />` |147148## Best Practices149150- **NuxtLink for all internal routes** - enables prefetching and client-side navigation151- **NuxtImg for all images** - automatic optimization, lazy loading, responsive152- **NuxtTime for all dates** - SSR-safe, automatic localization153- **Always provide alt text** for images154- **Use `loading="eager"`** for above-the-fold images155- **Use sizes prop** for responsive images156157## Resources158159- NuxtLink: https://nuxt.com/docs/api/components/nuxt-link160- NuxtImg: https://image.nuxt.com/usage/nuxt-img161- NuxtPicture: https://image.nuxt.com/usage/nuxt-picture162- NuxtTime: https://nuxt.com/docs/api/components/nuxt-time163