ShortIQ

ShortIQ

AI

50 AI Prompts for Vue.js and Nuxt.js Development

Developer-tested AI prompts for Vue 3, Nuxt 3, Pinia, Vue Router, Composition API, component architecture, data fetching, testing with Vitest, and production deployment.

June 27, 2026ShortIQ Editorial Team

Why Vue.js and Nuxt.js Developers Benefit from AI Prompts

Vue 3 and Nuxt 3 have their own conventions that differ significantly from React and Next.js — the Composition API, script setup syntax, Pinia stores, and Nuxt server routes all have specific patterns that AI models do not always get right without guidance. A well-structured prompt that provides your tech stack, Vue version, and API style produces dramatically more accurate code.

The most common frustration with AI-generated Vue code is receiving Options API output when you are using Composition API, or generic state management advice instead of Pinia-specific patterns. The prompts in this guide solve that by giving the model enough context to produce idiomatic Vue 3 code every time.

  • Generate Composition API components with script setup and TypeScript without Options API drift
  • Get accurate Pinia store patterns including getters, actions, and persistence
  • Build Nuxt 3 pages, layouts, middleware, and server routes with correct file conventions
  • Write Vue Test Utils and Vitest tests for components and composables
  • Scaffold reusable composables for data fetching, form validation, and state logic

Vue 3 Project Setup and Configuration Prompts

A good project setup prompt produces a working Vite configuration, correct tsconfig settings for Vue SFCs, path aliases, and the initial store and router setup. Providing the full list of libraries upfront prevents the model from suggesting alternatives you are not using.

These prompts cover the initial scaffold, environment variable setup, and Tailwind CSS integration that most Vue 3 projects need from day one.

text
Act as a Vue 3 expert.

Task:
Set up a new Vue 3 project with Vite, TypeScript, Vue Router 4, Pinia, and Tailwind CSS.

Provide:
1. The vite.config.ts with path aliases (@/ pointing to src/)
2. The tsconfig.json configured for Vue SFCs and strict mode
3. The Pinia setup in main.ts with a typed user store
4. The Vue Router 4 setup with typed routes and lazy-loaded pages
5. The Tailwind CSS configuration and the postcss.config.js

Tech stack: Vue 3.4, Vite 5, TypeScript 5, Vue Router 4, Pinia 2, Tailwind CSS 3

Composition API and Script Setup Prompts

The Composition API with script setup is the standard for Vue 3. These prompts generate typed components, convert Options API code to Composition API, and scaffold custom composables that encapsulate reusable logic.

When generating component code, always specify script setup, TypeScript, and whether the component uses defineProps, defineEmits, or defineExpose. Without this context the model may revert to Options API or produce untyped props.

text
Act as a Vue 3 TypeScript expert.

Task:
Build a reusable DataTable component using script setup and TypeScript.

Requirements:
- Generic type T for row data so columns are typed to the row shape
- Props: columns (label + key), rows (T[]), loading (boolean), emptyMessage (string)
- Emit: row-click with the clicked row as payload
- Slot: custom-cell(column, row) for overriding specific cell rendering
- Show a skeleton loader when loading is true
- Show emptyMessage when rows is empty and loading is false

Use: Vue 3, script setup, TypeScript, defineProps with generic, defineEmits, defineSlots

Pinia State Management Prompts

Pinia is the official state management library for Vue 3. These prompts generate typed stores, handle async actions with loading and error states, and set up persistence with pinia-plugin-persistedstate. Provide your API endpoints and state shape in the prompt for accurate output.

The most important context to include is the store name, the full state interface, which state should be persisted, and what the async actions should call. Without the API contract the model invents endpoints that do not match your backend.

text
Act as a Vue 3 Pinia expert.

Task:
Create a typed Pinia store for user authentication.

State:
- user: { id: string, email: string, role: 'admin' | 'user' } | null
- token: string | null
- isLoading: boolean
- error: string | null

Getters:
- isAuthenticated: returns true when token is not null
- isAdmin: returns true when user.role is admin

Actions:
- login(email, password): POST /api/auth/login, store token and user
- logout(): clear token and user, redirect to /login
- refreshToken(): POST /api/auth/refresh, update token

Persist: token and user using pinia-plugin-persistedstate (localStorage)
Use: Pinia defineStore with setup syntax, TypeScript

Nuxt.js Routing, Layouts, and Middleware Prompts

Nuxt 3 uses a file-based routing system where the folder structure under pages/ defines the routes. Layouts, error pages, and middleware each have their own conventions. These prompts generate the correct file structure and code for common Nuxt 3 patterns.

Specify whether you need a global middleware (applies to all routes), a named middleware (applied per-page with definePageMeta), or an inline middleware defined in the page component itself. The distinction matters for the generated code.

text
Act as a Nuxt 3 expert.

Task:
Set up a Nuxt 3 application with the following routing and layout structure:

Layouts:
- default.vue: navigation bar with links to /, /dashboard, /settings, and a logout button
- auth.vue: centered card layout for /login and /register pages

Middleware:
- auth.ts (named middleware): redirect unauthenticated users to /login
  Applied to /dashboard and all routes under /admin/
- guest.ts (named middleware): redirect authenticated users away from /login

Auth state comes from useAuthStore().isAuthenticated (Pinia store).

Pages needed: index.vue, login.vue, dashboard.vue, admin/users.vue
Use: Nuxt 3, TypeScript, definePageMeta for middleware assignment

Data Fetching with useFetch and useAsyncData Prompts

Nuxt 3 provides useFetch and useAsyncData as the primary data fetching composables. Both handle server-side rendering, client-side navigation, and automatic cache invalidation. The key difference is that useFetch is a shorthand for useAsyncData combined with $fetch, and is the preferred option for most use cases.

These prompts generate typed data fetching composables with pagination, error handling, and reactive parameters. Always specify whether the data should be fetched on the server, the client, or both, since this affects which composable and options to use.

text
Act as a Nuxt 3 TypeScript developer.

Task:
Write a composable called useProducts that fetches paginated product data.

API endpoint: GET /api/products?page=1&limit=20
Response shape: { data: Product[], total: number, page: number, limit: number }
Product type: { id: string, name: string, price: number, category: string, stock: number }

Requirements:
- Accept page and limit as reactive ref parameters
- Automatically refetch when page changes
- Return: products, total, currentPage, pending, error
- Use a unique cache key that includes the page number
- Handle API errors with a typed error object

Use: Nuxt 3 useFetch, TypeScript, composable pattern

Testing Vue Components with Vitest and Vue Test Utils Prompts

Vitest is the standard test runner for Vue 3 Vite projects. Vue Test Utils provides the mounting and querying utilities. These prompts generate component tests, composable unit tests, and Pinia store tests with correct setup and teardown.

The most effective testing prompts include the full component source code, the list of scenarios to cover, and which utilities to use. Without the component code the model generates generic tests that do not match your actual props, emits, or slot structure.

text
Act as a Vue 3 testing expert.

Task:
Write Vitest unit tests for a LoginForm component using Vue Test Utils.

Component behavior:
- Has email input, password input, and a submit button
- On submit, emits a login event with { email, password }
- Shows an error message when email field is empty
- Disables submit button when the loading prop is true
- Shows a spinner inside the button when loading is true

Test scenarios:
1. Renders all form fields
2. Emits login event with correct data on valid submit
3. Shows validation error when email is empty on submit
4. Submit button is disabled when loading prop is true
5. Spinner is visible when loading is true

Use: Vitest, @vue/test-utils, TypeScript — no mocking of child components

Performance Optimization and Deployment Prompts

Vue 3 has built-in performance tools including v-memo for skipping subtree re-renders, shallowRef for large objects that do not need deep reactivity, and defineAsyncComponent for splitting the bundle by route or feature.

For Nuxt 3, performance prompts cover static site generation (nuxt generate), image optimization with @nuxt/image, payload extraction for large datasets, and deployment to Vercel, Netlify, or a Node.js server. Always specify your deployment target since it affects the Nuxt config nitro preset.

text
Act as a Vue 3 performance expert.

Task:
Audit this Vue 3 component for performance issues and provide fixes.

Focus areas:
1. Unnecessary re-renders — identify where v-memo or shallowRef would help
2. Computed properties that are recalculated too often
3. Event handlers that need debouncing or throttling
4. Large lists that should use virtual scrolling (vue-virtual-scroller)
5. Heavy child components that should use defineAsyncComponent
6. Watchers that trigger too broadly — suggest more specific watch targets

For each issue:
- Explain why it causes a performance problem
- Show the before and after code
- Estimate the impact (high / medium / low)

Component: [paste your component here]

FAQ

What is the best way to use AI for Vue.js development?

Always specify Vue 3, script setup syntax, TypeScript, and your state management library (Pinia) in the prompt. Without this context the model may generate Vue 2 Options API code or use Vuex instead of Pinia. Include the tech stack at the top of every prompt.

Do these prompts work with Vue 2?

Most prompts target Vue 3 and the Composition API. For Vue 2, add Options API to your prompt and replace script setup references with data(), computed, methods, and Vuex. Specify the Vue version explicitly so the model does not mix APIs.

Can I use these prompts with Nuxt 3?

Yes. Sections 5 and 6 target Nuxt 3 specifically with routing, layouts, middleware, and useFetch patterns. For other sections, add Nuxt 3 to the tech stack line in the prompt and the model will use Nuxt-specific conventions such as useNuxtApp, useRuntimeConfig, and server routes.

What is the difference between Options API and Composition API?

Options API organises component logic by type: data(), computed, methods, watch, and lifecycle hooks are separate blocks. Composition API organises logic by feature: all the state, logic, and side effects for a feature live together in the setup function or script setup block. Composition API is the standard for Vue 3 and produces more reusable, testable code.

How do I prompt AI to generate a Pinia store?

Describe the state interface, list every getter and action, specify the API endpoints the actions should call, and state whether any fields need persistence. The prompt in Section 4 covers this pattern in full. The more specific the state shape and API contract, the more accurate the generated store.

Can AI help write tests for Vue components?

Yes. Provide the full component source code, the list of test scenarios, and which testing library to use (Vitest and Vue Test Utils). AI generates accurate tests when given the component code directly. Without the source, it produces generic tests that do not match your actual props or emits.

What AI model works best for Vue.js code?

Claude and GPT-4 both handle Vue 3 and Nuxt 3 well. Claude produces cleaner TypeScript types and tends to follow script setup conventions more consistently. Either model improves significantly when given explicit context about your Vue version, API style, and tech stack — so prompt quality matters more than model choice.

Do these prompts work with TypeScript?

All prompts in this guide include TypeScript in the tech stack line. Specify your tsconfig strict mode setting and the TypeScript version when generating complex types or utility functions. For Pinia stores, include the full state interface in the prompt so the model generates accurate typed actions and getters.

Related free tools

If you want to turn this topic into action, use one of ShortIQ's free tools for campaign planning, UTM structure, or QR distribution.

Continue Reading

Explore more guides on link shortener SaaS strategy, Bitly alternatives, and white label link management.

Free newsletter

Get new guides in your inbox

We publish practical guides on dev tooling, prompt engineering, marketing workflows, and deployment. No fluff — straight to the point.

No spam. Unsubscribe any time.

Was this article helpful?

Tell us if this guide solved the problem or what was still missing. We use this to improve the blog and only follow up if you explicitly allow it.

We use this to improve tutorials, examples, and technical depth.