Skip to content

Vue.js Workflow Recipes

You picked Vue for its gentle learning curve and now you need to ship a complex SPA with TypeScript, Pinia stores, and composables that your team can actually maintain. These recipes give you production-ready prompts that produce idiomatic Vue 3 code — not Options API leftovers dressed up as Composition API.

  • Prompts for generating Vue 3 components with <script setup> and TypeScript
  • Pinia store patterns with proper typing and persistence
  • Composable recipes for reusable logic extraction
  • Testing prompts for Vue Test Utils and Vitest

Recipe 1: Scaffold a Vue 3 Component with Script Setup

Section titled “Recipe 1: Scaffold a Vue 3 Component with Script Setup”

Scenario: You need a new feature component that follows your team’s conventions — <script setup>, typed props with defaults, typed emits, and scoped styles.

Expected output: A .vue SFC with typed <script setup>, a responsive template, and a .test.ts file.


Recipe 2: Build a Pinia Store with Persistence and Undo

Section titled “Recipe 2: Build a Pinia Store with Persistence and Undo”

Scenario: You need a cart store that persists across page refreshes, supports undo, and integrates with Vue DevTools.

Expected output: Store file, CartItem type definition, and test file covering all actions and undo.


Scenario: Multiple components duplicate the same fetch-with-loading-state pattern, debounced search, and permission checks. Extract them into composables.

Expected output: Four composable files, four test files, type definitions, and a barrel export.


Recipe 4: Multi-Step Form with Per-Step Validation

Section titled “Recipe 4: Multi-Step Form with Per-Step Validation”

Scenario: You need a checkout form with 4 steps where each step validates before advancing and the user can navigate back without losing data.

Expected output: Six component files, one composable, Zod schemas for each step, and integration tests.


Recipe 5: Virtual Data Table for Large Datasets

Section titled “Recipe 5: Virtual Data Table for Large Datasets”

Scenario: Your admin panel needs to display 50,000 log entries without freezing the browser.

Expected output: VirtualDataTable component, column type definitions, CSV export utility, and a performance test.


Recipe 6: Theme System with Provide/Inject

Section titled “Recipe 6: Theme System with Provide/Inject”

Scenario: You need a theme system that lets any component access and toggle between light, dark, and system themes without prop drilling.

Expected output: Provider component, composable, toggle component, type definitions, and tests.


Recipe 7: Lazy-Loaded Routes with Per-Route Skeletons

Section titled “Recipe 7: Lazy-Loaded Routes with Per-Route Skeletons”

Scenario: Your Vue Router setup loads all page components eagerly, bloating the initial bundle.

Expected output: Updated router config, RouterViewWithSuspense component, usePrefetch composable, and skeleton components.


Scenario: Your app needs a global toast notification system that any component can trigger without prop drilling.

Expected output: ToastProvider, Toast component, useToast composable, and tests.


Recipe 9: Internationalization with Vue I18n

Section titled “Recipe 9: Internationalization with Vue I18n”

Scenario: Your SPA needs to support English, Spanish, and Japanese with lazy-loaded locale files and pluralization.

Expected output: I18n config, three locale files, locale switcher, routing composable, and integration tests.


Scenario: Your app feels static. You need reusable transition components for page changes, list animations, and micro-interactions.

Expected output: Six transition components, a demo page, and type definitions for all props.


Recipe 11: WebSocket Integration with Auto-Reconnect

Section titled “Recipe 11: WebSocket Integration with Auto-Reconnect”

Scenario: Your dashboard needs real-time updates from a WebSocket that handles disconnections gracefully.

Expected output: useWebSocket composable, useRealtimeTodos composable, and tests for reconnection logic.


Scenario: Your component library lacks documentation. New team members cannot discover or understand existing components.

The Storybook installer is interactive, so how you kick it off is the one place this recipe diverges across tools:

In Agent mode, ask Cursor to run npm create storybook@latest and answer the scaffold prompts (Vue 3 + Vite), then paste the recipe prompt below so it wires up the stories and addons.

Expected output: Storybook config, 5 story files with variants and docs, the a11y and Vitest addons, and one interaction test.