Skip to content

Nuxt 3 Development Recipes

Nuxt 3 gives you file-based routing, auto-imports, server routes, and hybrid rendering out of the box. These recipes help you use AI tools to build on that foundation without fighting the framework’s conventions. Every prompt here produces code that respects Nuxt’s directory structure, leverages auto-imports, and handles SSR/CSR boundaries correctly.

  • Server route recipes that handle auth, validation, and database access
  • Composable patterns for data fetching with useFetch and useAsyncData
  • Middleware and plugin recipes for auth guards and global state
  • Deployment prompts for Vercel, Cloudflare, and Netlify edge

Recipe 1: Server API Route with Zod Validation

Section titled “Recipe 1: Server API Route with Zod Validation”

Scenario: You need a POST endpoint for creating blog posts with Zod validation, auth checking, and proper error responses.

Expected output: Server route file, Zod schema, and test file with 4 test cases.


Recipe 2: Standardized Data Fetching Composable

Section titled “Recipe 2: Standardized Data Fetching Composable”

Scenario: Your pages call useFetch directly with duplicated error handling. You need a composable that standardizes this.

Expected output: Composable file with typed wrappers, ApiError type, and tests.


Recipe 3: Auth Middleware with JWT Refresh

Section titled “Recipe 3: Auth Middleware with JWT Refresh”

Scenario: Protected pages need to check authentication and transparently refresh expired tokens without redirecting the user.

Expected output: Two middleware files, one plugin, one composable, and integration tests.


Scenario: Every page needs consistent meta tags, structured data, and an auto-generated sitemap.

Expected output: Module directory with index.ts, composable, Nitro plugins for sitemap and robots, and tests.


Scenario: Your marketing pages should be static, your dashboard SSR, and your blog ISR with 1-hour revalidation.

Expected output: Updated nuxt.config.ts, render mode composable, and debug page.


Recipe 6: Real-Time Updates with Server-Sent Events

Section titled “Recipe 6: Real-Time Updates with Server-Sent Events”

Scenario: Your dashboard needs live updates for order status changes without WebSocket complexity.

Expected output: SSE server route, two composables, Pinia integration, and tests.


Recipe 7: Shared Nuxt Layer for Multi-App Reuse

Section titled “Recipe 7: Shared Nuxt Layer for Multi-App Reuse”

Scenario: Three Nuxt apps share components, composables, and styles. You need a shared layer.

Expected output: Layer directory with config, 7 components, 3 composables, Tailwind preset, and integration test.


Scenario: Your Nuxt app needs type-safe database queries, migrations, and seeding.

Expected output: Schema file, query functions, config, seed script, and query tests.


Scenario: You want a blog powered by Markdown files with frontmatter, code highlighting, and table of contents.

Expected output: Nuxt Content config, sample posts, blog pages, custom prose component, RSS route, and tests.


Recipe 10: Cloudflare Workers Edge Deployment

Section titled “Recipe 10: Cloudflare Workers Edge Deployment”

Scenario: Deploy your Nuxt app to Cloudflare Workers with D1 database, KV caching, and R2 storage.

Expected output: Nitro config, wrangler.toml, binding utilities, session middleware, upload route, and D1 queries.


Scenario: Your Nuxt app has zero tests. You need coverage for components, server routes, and composables.

Expected output: Vitest config, test utilities, component tests, server route tests, composable tests, and updated scripts.


Scenario: Your Nuxt app scores 60 on Lighthouse. Page transitions feel slow and the bundle is over 1 MB.

Expected output: Updated nuxt.config, NuxtImg replacements, chunk splitting config, and performance comparison.