AI
50 AI Prompts for Vue.js 3 and TypeScript Frontend Development
50 practical AI prompts for building Vue.js 3 applications with TypeScript. Covers Vite setup, Composition API, Pinia state management, Vue Router, form validation, API integration, testing with Vitest, and deployment.
Getting the Most from These Vue.js Prompts
Vue.js 3 with the Composition API and script setup syntax is a significantly different developer experience from Vue 2. These prompts assume Vue 3, TypeScript, the Composition API with script setup, Pinia for state management, and Vite as the build tool. If you are still on Vue 2 or using the Options API, specify this when running any prompt.
Vue.js gives you more choices than React or Angular — for routing, state management, form handling, and component libraries. When running a prompt that involves one of these areas, name the specific libraries your project uses so the generated code matches your stack rather than using whatever the model defaults to.
Project Setup and Architecture (Prompts 1-8)
Prompt 1: Create a Vue.js 3 project with Vite, TypeScript, Vue Router 4, Pinia, Tailwind CSS, and ESLint with the Vue recommended config. Show the create-vite command, the post-install configuration for Tailwind, the main.ts that registers all plugins, and a recommended folder structure separating views, components, composables, stores, and services.
Prompt 2: Write a Vue.js 3 main.ts that registers global plugins and provides, handles initialization errors gracefully, shows a loading screen while async plugins initialize, and registers global components for icons and a notification system. Prompt 3: Create a Vue.js 3 environment configuration system using import.meta.env. Define a typed config object that reads Vite environment variables with fallback defaults, validates required variables at startup and throws with a clear error if any are missing, and exports a single config object used throughout the application.
- Prompt 4: Write a Vue.js 3 router configuration with four route groups: public routes (home, blog, pricing), auth routes (login, register, forgot-password), protected dashboard routes that require authentication via a navigation guard, and an admin section that requires an admin role.
- Prompt 5: Create a Vue.js 3 navigation guard that reads the authentication state from a Pinia store, redirects unauthenticated users to the login page with a redirect query parameter, restores the original destination after login, and handles the case where the auth state is loading asynchronously.
- Prompt 6: Write a Vue.js 3 layout system using router-meta. Define three layouts: DefaultLayout (with nav and footer), AuthLayout (centered card, no nav), and DashboardLayout (sidebar nav). Show how to specify the layout per route in the router config and how the App.vue dynamically renders the correct layout component.
- Prompt 7: Create a Vue.js 3 plugin that provides a global toast notification system accessible from any component via useToast(). The plugin should queue notifications, show them as a stack in the top-right corner, auto-dismiss after a configurable timeout, and support success, error, warning, and info variants.
- Prompt 8: Write a Vue.js 3 error boundary component that catches errors from child components using the onErrorCaptured hook, shows a fallback UI with a retry button, logs the error with component context, and optionally reports the error to an error tracking service.
Components and Composition API (Prompts 9-22)
Prompt 9: Write a reusable Vue.js 3 DataTable component with script setup and TypeScript. Accept a generic items prop typed with defineProps<{ items: T[] }>, column definitions with headers and accessor keys, sortable columns with a controlled sort state, row click events, and an empty state slot. Use computed properties for sorted items.
Prompt 10: Create a Vue.js 3 Modal component using Teleport to render in the document body. Include open and close animations with Vue Transition, trap focus inside the modal when open, close on Escape key and backdrop click, and expose open and close methods via defineExpose for parent component control. Prompt 11: Write a Vue.js 3 composable called useDebounce that returns a debounced version of any function. Use it in a search input component where the API call fires 300ms after the user stops typing. Show the composable implementation with proper TypeScript generics and the component that uses it with a ref for the search term.
- Prompt 12: Create a Vue.js 3 IntersectionObserver composable called useIntersectionObserver that tracks when an element enters the viewport. Use it to implement infinite scroll in a list component that loads more items when the sentinel element becomes visible.
- Prompt 13: Write a Vue.js 3 composable called useFetch that wraps the native fetch API with reactive state for data, error, and loading. Support request cancellation when the component unmounts using AbortController, and automatic refetch when a reactive URL ref changes.
- Prompt 14: Create a Vue.js 3 Dropdown component that renders a list of options, filters them with a search input, supports single and multi-select modes, closes on outside click using a directive, is fully keyboard navigable (arrow keys, Enter to select, Escape to close), and emits typed update:modelValue events.
- Prompt 15: Write a Vue.js 3 virtual scroll component that renders only visible rows for a list of 10,000 items. Calculate visible item indices from the scroll position and container height, render a spacer div above and below the visible items to maintain scroll position, and handle variable-height items.
- Prompt 16: Create a Vue.js 3 drag-and-drop list component that reorders items using the native HTML5 drag API. Track drag state reactively, update the items array on drop, emit a reorder event with the new array, and show a visual drop target indicator.
- Prompt 17: Write a Vue.js 3 composable called useLocalStorage that keeps a ref in sync with localStorage. It should initialise from the stored value if it exists, update localStorage when the ref changes using a watcher, handle JSON serialisation and deserialisation, and accept a default value.
- Prompt 18: Create a Vue.js 3 image lazy loading composable that uses IntersectionObserver to load images only when they scroll into view. Show it being used as a directive (v-lazy-load) on img elements, with a low-quality placeholder shown while the full image loads.
- Prompt 19: Write a Vue.js 3 global confirm dialog composable called useConfirm. It should show a modal with a message and OK/Cancel buttons, return a promise that resolves to true or false based on the button clicked, and be callable from any component or Pinia action without a local component reference.
- Prompt 20: Create a Vue.js 3 form stepper component that manages a multi-step form. Each step is a separate child component. The stepper tracks the current step, validates the current step before advancing, shows a progress indicator, and exposes navigation methods to child steps via provide/inject.
- Prompt 21: Write a Vue.js 3 animated number component that smoothly transitions a displayed number when its value changes. Accept a target value prop and a duration prop, use requestAnimationFrame for smooth animation, apply an easing function, and format the output with Intl.NumberFormat.
- Prompt 22: Create a Vue.js 3 composable called useClipboard that copies text to the clipboard using the Clipboard API, falls back to document.execCommand for older browsers, returns a reactive copied boolean that reverts to false after 2 seconds, and handles errors gracefully.
Pinia, Forms, API Integration, and Testing (Prompts 23-50)
Prompt 23: Write a Pinia auth store with state for user, token, and isLoading. Include actions for login (calls the API, saves the token to localStorage and state, redirects to dashboard), logout (clears state and localStorage, redirects to login), and fetchCurrentUser (used on app init to restore session from token). Add a getter isAuthenticated that derives from the user state.
Prompt 24: Create a Pinia store for a shopping cart with items, quantity management, total price calculation, and persisted state using the pinia-plugin-persistedstate package. Include actions for addItem, removeItem, updateQuantity, and clearCart. Add a computed getter for totalItems and totalPrice with currency formatting. Prompt 25: Write a Pinia store that manages paginated list data. Include state for items, currentPage, totalPages, isLoading, and error. The fetchPage action should cancel the previous in-flight request before making a new one, and the store should expose a computed getter for whether there is a next or previous page.
- Prompt 26: Create a Vue.js 3 form with VeeValidate and Zod schema validation. Build a registration form with name, email, password, and password confirmation fields. Validate using a Zod schema, show field-level errors as the user types, disable the submit button until the form is valid, and handle API submission errors by mapping server error messages to specific fields.
- Prompt 27: Write a Vue.js 3 Axios instance setup with request and response interceptors. The request interceptor adds the JWT from the auth store to every request. The response interceptor catches 401 responses, attempts a token refresh, retries the original request once, and redirects to login if the refresh also fails.
- Prompt 28: Create a Vue.js 3 API service layer using a composable called useApi. It should wrap Axios calls with reactive loading and error state, support request cancellation, handle common error formats from the API, and type the response with a generic parameter.
- Prompt 29: Write Vitest unit tests for a Vue.js 3 Pinia store. Test the initial state, test that the login action calls the API and updates state correctly, test that logout clears the state and localStorage, and test the isAuthenticated getter for both logged-in and logged-out states.
- Prompt 30: Create a Vue Test Utils component test for a Vue.js 3 DataTable component. Mount the component with mock data, test that the correct number of rows renders, test that clicking a column header triggers sorting, test that the empty state slot renders when the items array is empty, and test that row click events emit the correct item.
- Prompt 31: Write a Vue.js 3 i18n setup using vue-i18n 9. Configure English and French translations, use the Composition API useI18n hook in components, show how to switch locales at runtime, persist the locale choice to localStorage, and handle plural forms for item count messages.
- Prompt 32: Create a Vue.js 3 theme system that supports light and dark mode. Detect the system preference with matchMedia, allow the user to override it, persist the choice to localStorage, and toggle a data-theme attribute on the html element. Show how to define CSS variables for each theme and use them in Tailwind.
- Prompt 33: Write a Vue.js 3 infinite scroll implementation for a blog post list. Use a Pinia store that tracks loaded pages, an IntersectionObserver on a sentinel element at the bottom of the list, a loading skeleton component shown while fetching, and an end-of-list message when all posts have been loaded.
FAQ
Should I use Vue 3 Options API or Composition API?
Use the Composition API with script setup for all new Vue 3 projects. It has better TypeScript inference, enables cleaner code reuse through composables, and the Vue core team considers it the idiomatic Vue 3 approach. The Options API is still fully supported and fine for migrating Vue 2 components, but new components should use Composition API.
Should I use Pinia or Vuex for Vue 3?
Use Pinia. It is the officially recommended state management library for Vue 3, replacing Vuex. Pinia has better TypeScript support, a simpler API without mutations, support for multiple stores without a root store, and works with the Vue DevTools. Vuex 4 works with Vue 3 but Pinia is the forward-looking choice.
What is the best component library for Vue.js 3?
PrimeVue, Vuetify 3, and Quasar Framework are the most complete options with large component sets. For lightweight accessible components, Headless UI for Vue and Radix Vue give you unstyled components you control completely with Tailwind. For data grids specifically, AG Grid has the best Vue 3 support for large datasets. The best choice depends on whether you need a full design system or just accessible primitives.
Can I use these prompts for a Nuxt 3 project?
Many of the component and composable prompts work directly in Nuxt 3. The main differences are in setup and routing: Nuxt uses file-based routing, so the Vue Router configuration prompts do not apply directly. The store, component, form, and API prompts all work with minimal changes. Add your nuxt.config.ts and the relevant Nuxt module list to prompts so the model generates Nuxt-compatible code rather than generic Vue 3.
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.