vue-best-practices

Provide Vue.js 3 best practices for reactivity, components, templates, and TypeScript.

2|Updated Oct 5, 2024
One-click install
npx skills add https://github.com/remoodle/heresy --skill vue-best-practices-remoodle
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: vue-best-practices
Source: https://github.com/remoodle/heresy/tree/main/src/calendar/.agents/skills/vue-best-practices
Command: npx skills add https://github.com/remoodle/heresy --skill vue-best-practices-remoodle

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps developers write better, more maintainable, and performant Vue.js applications by providing best practices and solutions for common pitfalls.

Core Features & Use Cases

  • Reactivity: Guidance on ref vs reactive, destructuring, and watcher behavior.
  • Components: Best practices for props, emits, slots, and composition API patterns.
  • Templates: Tips on v-if, v-for, and performance optimizations.
  • Use Case: You're building a complex Vue component and are unsure about the best way to handle state management or component communication. This Skill provides clear, actionable advice based on the latest Vue 3 patterns.

Quick Start

Use the vue-best-practices skill to understand how to correctly use ref versus reactive for state management.

Frequently Asked Questions about vue-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
What is the best way to use ref versus reactive for state management in Vue 3?

The best way to handle state management in Vue 3 is by understanding the reactivity differences between ref and reactive. Use ref for primitive values and reactive for objects, ensuring you avoid destructuring pitfalls that break reactivity tracking.

How do I optimize Vue templates using v-if and v-for without hurting performance?

To optimize Vue templates, avoid using v-if and v-for on the same element to prevent unnecessary computations. Apply performance optimizations by strategically separating conditional rendering and list rendering to minimize DOM updates.

How does the Composition API improve component design over the Options API?

The Composition API improves component design by allowing you to group related logic together within <script setup>, unlike the Options API which separates data, methods, and computed properties. This pattern yields more maintainable and reusable Vue components.

How do I integrate TypeScript with a Vue 3 project using script setup?

Integrate TypeScript with Vue 3 by leveraging the <script setup> block with TypeScript typing for props and emits. This approach provides type safety, and using Volar with vue-tsc ensures robust type checking across your application architecture.

Does this Vue 3 guidance cover Server-Side Rendering (SSR) best practices?

Yes, this Vue 3 guidance covers Server-Side Rendering (SSR) best practices. It addresses architectural patterns and common gotchas for building robust applications, ensuring your SSR implementations align with the latest Composition API patterns.

Why does destructuring reactive objects break reactivity in Vue 3?

Destructuring reactive objects breaks reactivity in Vue 3 because it detaches primitive properties from the underlying proxy. To maintain reactivity, use refs or pass reactive objects directly to watchers instead of destructuring them.