Skip to content
Skills Library
Programming · Building & coding

nuxt

/nuxt

Nuxt is the full-stack Vue framework with server-side rendering, auto-imports, file-based routing and a Nitro server for API routes. Use it when a user asks to build or fix a Nuxt app, set up per-route rendering (SSR, prerender, ISR, SPA), fetch data with useFetch or useAsyncData, write server/api endpoints, share state with useState, set page SEO meta, or deploy a Nuxt 3 or Nuxt 4 site.

Repository
skills ↗
Licence
Apache-2.0
Last repository change
25.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
2
Scripts
0
HTML comments
0
URLs in SKILL.md
2
Deprecation

No signals detected. Repository changed on 25.10.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Nuxt is the full-stack Vue framework with server-side rendering, auto-imports, file-based routing and a Nitro server for API routes. Use it when a user asks to build or fix a Nuxt app, set up per-route rendering (SSR, prerender, ISR, SPA), fetch data with useFetch or useAsyncData, write server/api endpoints, share state with useState, set page SEO meta, or deploy a Nuxt 3 or Nuxt 4 site.

Original author description

Nuxt is the full-stack Vue framework with server-side rendering, auto-imports, file-based routing and a Nitro server for API routes. Use it when a user asks to build or fix a Nuxt app, set up per-route rendering (SSR, prerender, ISR, SPA), fetch data with useFetch or useAsyncData, write server/api endpoints, share state with useState, set page SEO meta, or deploy a Nuxt 3 or Nuxt 4 site.

How it works

  1. Overview
  2. Instructions
  3. Examples
  4. Guidelines
Original SKILL.md headings · 185 lines, 1,002 words
SKILL.md preview
---
name: nuxt
description: >-
  Nuxt is the full-stack Vue framework with server-side rendering, auto-imports,
  file-based routing and a Nitro server for API routes. Use it when a user asks
  to build or fix a Nuxt app, set up per-route rendering (SSR, prerender, ISR,
  SPA), fetch data with useFetch or useAsyncData, write server/api endpoints,
  share state with useState, set page SEO meta, or deploy a Nuxt 3 or Nuxt 4 site.
license: Apache-2.0
compatibility: 'Nuxt 4.x (Nuxt 3 notes included); Node.js 22.22.3+, 24.15+ or 26+; npm, pnpm, yarn or bun'
metadata:
  author: terminal-skills
  version: "1.1.0"
  category: development
  repository: https://github.com/nuxt/nuxt
  tags: "vue, nuxt, ssr, fullstack, nitro"
---

# Nuxt

## Overview

Nuxt is the Vue meta-framework: file-based routing, auto-imported components and composables, server rendering with hydration, and a Nitro server that serves `server/api` endpoints and deploys to Node, serverless and edge platforms. The current major version is Nuxt 4. Its source folder is `app/` (pages, components, composables, layouts, `app.vue`), while `server/`, `public/` and `nuxt.config.ts` stay in the project root. Nuxt 3 projects keep those folders at the root.

## Instructions

### Create a project

```bash
npm create nuxt@latest shop-blog
cd shop-blog && npm install && npm run dev
```

The dev server listens on `http://localhost:3000`. `npm run build` writes `.output/`; run it with `node .output/server/index.mjs` (set `PORT` and `HOST` to change the listener). `npm run generate` prerenders a fully static site.

### Pages and data fetching

```vue
<script setup lang="ts">
const { data: posts } = await useFetch('/api/posts')
</script>

<template>
  <div>
    <h1>Blog</h1>
    <article v-for="post in posts" :key="post.slug">
      <NuxtLink :to="`/posts/${post.slug}`">
        <h2>{{ post.title }}</h2>
        <p>{{ post.excerpt }}</p>
      </NuxtLink>
    </article>
  </div>
</template>
```

```vue
<script setup lang="ts">
const route = useRoute('posts-slug')
const { data: post, error } = await useFetch(() => `/api/posts/${route.params.slug}`)

if (error.value) {
  throw createError({ statusCode: 404, statusMessage: 'Post not found', fatal: true })
}

useSeoMeta({
  title: () => post.value?.title,
  description: () => post.value?.excerpt,
  ogTitle: () => post.value?.title,
})
</script>

<template>
  <article v-if="post">
    <h1>{{ post.title }}</h1>
    <p>{{ post.content }}</p>
  </article>
</template>
```

`useFetch(url)` is `useAsyncData` plus `$fetch`: it runs on the server, ships the result in the payload and does not refetch on hydration. Use `useAsyncData(key, handler)` for anything that is not a plain URL. Use `$fetch` (not `useFetch`) inside event handlers such as a button click. `data` is a shallow ref; use `deep: true` if you mutate nested fields. `useRoute('posts-slug')` with the route name gives typed params.

### Server API routes

Files in `server/api/` become endpoints; the suffix picks the method (`index.get.ts`, `index.post.ts`). Anything exported from `server/utils/` is auto-imported in server code.

```typescript
// server/utils/posts.ts
export interface Post { slug: string; title: string; excerpt: string; content: string }

const posts: Post[] = [
  { slug: 'hello-nuxt', title: 'Hello Nuxt', excerpt: 'First post', content: 'Nitro serves this.' },
  { slug: 'routing-rules', title: 'Route rules', excerpt: 'Hybrid rendering', content: 'ISR, SSR and SPA per route.' },
]
export const listPosts = () => posts
export const findPost = (slug: string) => posts.find((p) => p.slug === slug)
```

```typescript
// server/api/posts/[slug].get.ts
export default defineEventHandler((event) => {
  const slug = getRouterParam(event, 'slug')!
  const post = findPost(slug)
  if (!post) throw createError({ statusCode: 404, statusMessage: 'Post not found' })
  return post
})
```

Validate request bodies instead of trusting `readBody`. `readValidatedBody` takes any function that throws on bad input, such as zod's `parse`; a failure answers 400.

Install the validator first with `npm install zod`.

```typescript
// server/api/posts/index.post.ts
import { z } from 'zod'
const schema = z.object({ title: z.string().min(3), content: z.string().min(1) })

export default defineEventHandler(async (event) => {
  const body = await readValidatedBody(event, schema.parse)
  setResponseStatus(event, 201)
  return { slug: body.title.toLowerCase().replace(/\s+/g, '-'), ...body }
})
```

Server middleware in `server/middleware/` runs on every request. Secrets belong in `runtimeConfig` (override `adminToken` at runtime with the `NUXT_ADMIN_TOKEN` environment variable):

```typescript
// server/middleware/auth.ts
export default defineEventHandler((event) => {
  const path = getRequestURL(event).pathname
  if (!path.startsWith('/api/admin')) return
  if (getHeader(event, 'authorization') !== `Bearer ${useRuntimeConfig(event).adminToken}`) {
    throw createError({ statusCode: 401, statusMessage: 'Unauthorized' })
  }
})
```

The `/api/admin/ping` route the middleware protects:

```typescript
// server/api/admin/ping.get.ts
export default defineEventHandler(() => ({ ok: true }))
```

### Rendering modes per route

```typescript
// nuxt.config.ts
export default defineNuxtConfig({
  compatibilityDate: '2025-07-15',
  runtimeConfig: { adminToken: '' },
  routeRules: {
    '/': { prerender: true },
    '/posts/**': { isr: 3600 },
    '/admin/**': { ssr: false },
  },
})
```

`prerender: true` builds the page once at build time, `isr: 3600` caches the rendered page on supported hosts (Vercel, Netlify) and revalidates hourly, `ssr: false` makes that section a client-rendered SPA.

### Shared state and composables

Anything in `app/composables/` is auto-imported. Use `useState` (never a module-level `ref`) for state shared between components, because module-level state leaks between requests on the server.

```typescript
// app/composables/useAuth.ts
interface User { id: string; name: string }

export function useAuth() {
  const user = useState<User | null>('user', () => null)
  const isLoggedIn = computed(() => user.value !== null)

  async function login(email: string, password: string) {
    user.value = await $fetch<User>('/api/auth/login', { method: 'POST', body: { email, password } })
  }
  async function logout() {
    await $fetch('/api/auth/logout', { method: 'POST' })
    user.value = null
    await navigateTo('/login')
  }
  return { user, isLoggedIn, login, logout }
}
```

## Examples

**"Add a /posts/<slug> page that returns 404 for unknown posts."** Create `app/pages/posts/[slug].vue` as above and the `[slug].get.ts` endpoint. Tested on Nuxt 4.5: `curl localhost:3000/posts/hello-nuxt` renders `<h1>Hello Nuxt</h1>` with the title in `<title>`, and `/posts/nope` returns status 404.

**"Protect /api/admin with a token."** Add the middleware above, set `NUXT_ADMIN_TOKEN=s3cret` when starting the server. A request without a header gets `401`; with `Authorization: Bearer s3cret` the handler answers `{"ok":true}`.

**"Reject bad input on POST /api/posts."** With the zod schema above, `{"title":"Ab"}` returns `400 Validation Error`, and `{"title":"My first post","content":"hi"}` returns `201` with `{"slug":"my-first-post",...}`.

## Guidelines

- Pick a rendering mode per route in `routeRules` instead of one global choice. Keep authenticated dashboards on `ssr: false` or SSR without caching.
- Nuxt 3 to 4 differences: the `app/` source directory, shallow `data` refs from `useFetch`/`useAsyncData`, and a `compatibilityDate` in `nuxt.config.ts` that pins Nitro and module defaults. Run `npx nuxt upgrade` and follow the official migration guide when moving a Nuxt 3 project.
- Fetch keys must be unique per distinct request; a repeated key shares one cached result.
- Do not put API secrets in `runtimeConfig.public` or in client code; only `runtimeConfig.public` is exposed to the browser.
- Use `v-html` only with sanitized content.
- Modules extend Nuxt through `modules: []` in `nuxt.config.ts`: for example `@nuxt/ui`, `@nuxt/image`, `@nuxt/content`, `nuxt-auth-utils`. Prefer official or well-maintained ones, and check that a module lists support for your Nuxt major version.
- Deploy by choosing the Nitro preset (`NITRO_PRESET=cloudflare_pages npm run build`, or let Vercel and Netlify auto-detect). For a plain server use the Node output above.
Files in this package (2)
  • SKILL.md 8 KB
  • _scores.json 1 KB

Versions

RepositoryScoreLicence
This page · TerminalSkills/skills100Apache-2.0
vercel-labs/emulate100Apache-2.0
G1Joshi/Agent-Skills100MIT
chrishuffman5/domain-expert100MIT
PIXARTSeu/Synapse100AGPL-3.0
dkbnull/hello-skill96MIT
kimjinwoo4/vue-skills90MIT
pleaseai/claude-code-plugins85MIT
YuDefine/nuxt-supabase-starter85MIT

Database snapshot: 13.11.2026 · package version 8e52b45c7bc1 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 2 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100nuxt-data
    Nuxt 5 data management with useFetch, useAsyncData, useState, and Pinia. Use when creating composables, fetching data, managing state, or debugging reactive/SSR data issues.
  • 90vue-nuxt
    Use this skill when the user says 'Nuxt', 'Nuxt 3', 'Nuxt structure', 'Nuxt composables', 'Nuxt server routes', 'useFetch', 'useAsyncData', 'Nuxt layers', 'Nuxt architecture', or when building a Nuxt 3 application. This skill enforces: directory-based routing in pages/, useFetch…
  • 95nuxt-data
    | Nuxt 4 data management: composables, data fetching with useFetch/useAsyncData, and state management with useState and Pinia. Use when: creating custom composables, fetching data with useFetch or useAsyncData, managing global state with useState, integrating Pinia, debugging…
  • 100vue-nuxt
    Use when building or reviewing a Vue 3 + Nuxt 4 app — `<script setup>` reactivity, SSR/SSG/hybrid `routeRules`, the `app/`+`server/` layout, SSR-safe fetching (`useFetch`/`useAsyncData`) and state (`useState`/Pinia), Nitro routes, hydration mismatches, Nuxt 3→4 migration. NOT…
  • 95nuxt3
    Nuxt 3 full-stack Vue framework. Covers file-based routing, data fetching, server routes, and auto-imports. Use when building Nuxt applications. USE WHEN: user mentions "Nuxt", "Nuxt 3", asks about "useFetch", "Nuxt server routes", "Nitro", "Nuxt auto-imports", "Nuxt…
  • 85nuxt-optimizer
    Audit and optimize Nuxt apps (Nuxt 4.6, Nuxt 5 compatibility flags, Vue 3.5, Vite 8, Nitro) for SSR/hybrid rendering and TTFB, useFetch/useAsyncData payload size and refetch waterfalls, route rules/ISR/SWR/caching correctness, server-route and database latency, bundle size and…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.