- Home
- Skills
- Long36708
- Longmo Skills
- Vue3 Best Practices
vue3-best-practices_skill
- Python
0
GitHub Stars
1
Bundled Files
2 months ago
Catalog Refreshed
4 months ago
First Indexed
Readme & install
Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.
Installation
Preview and clipboard use veilstrat where the catalogue uses aiagentskills.
npx veilstrat add skill long36708/longmo-skills --skill vue3-best-practices- SKILL.md9.9 KB
Overview
This skill is a practical Vue 3 best-practices guide focused on Composition API, <script setup>, Pinia, TypeScript integration, and performance optimization. It distills patterns for modular, type-safe, and high-performance Vue applications. The guidance is implementation-oriented with examples for composables, stores, reactivity, and routing.
How this skill works
It inspects and documents concrete patterns: project structure, naming conventions, reactive choices (ref/reactive/shallowRef), and component APIs (defineProps, defineEmits, defineExpose). It codifies composable design, Pinia setup stores, and migration steps from Options API, plus targeted performance techniques like v-memo, lazy routes, and shallowRef for heavy instances. Examples and small code snippets illustrate recommended usage and anti-patterns to avoid.
When to use it
- Starting a new Vue 3 project to establish structure and conventions
- Converting Options API components to Composition API and <script setup>
- Designing reusable composables and typed component APIs with TypeScript
- Implementing Pinia stores and consistent state patterns across the app
- Diagnosing reactivity issues or improving frontend performance
Best practices
- Prefer <script setup lang="ts"> with explicit imports and top-level await support
- Name composables with use prefix and return an object of reactive state and methods
- Use ref for primitives and nullable objects; reactive for non-destructured objects; use toRefs when destructuring
- Favor Setup-style Pinia stores (defineStore with setup) and keep state flat with computed getters
- Type props, emits, slots and components (generics supported) to ensure compile-time safety
- Apply performance patterns: route lazy loading, defineAsyncComponent, v-memo, KeepAlive, and shallowRef for heavy external instances
Example use cases
- Create a composable useFetch that accepts a ref or getter and returns data, error, loading, refresh
- Refactor an Options API page into <script setup lang="ts"> with typed props/emits and composables
- Implement a Pinia user store with token, user state, computed getters and async actions
- Optimize a large list component using v-memo and route/lazy-load heavy child components
- Build a generic list component using TypeScript generics to type items and select events
FAQ
Use ref for primitives, nullable objects, or when you need to replace the whole value; use reactive for objects/arrays you will not destructure. If you destructure reactive, use toRefs to preserve reactivity.
Do I need to name components with defineOptions?
Name components when they are recursive, used with KeepAlive include/exclude, or when you want clearer DevTools debugging. For recursive components naming is required.