Now liveThe Skillselion MCP - thousands of ranked skills, loaded into your agent mid-task. No install.Get it →
hyf0 avatar

Vue Options Api Best Practices

  • 2.2k installs
  • 2.8k repo stars
  • Updated May 30, 2026
  • hyf0/vue-skills

This is a copy of vue-options-api-best-practices by vuejs-ai - installs and ranking accrue to the original listing.

vue-options-api-best-practices is a Vue agent skill that prevents common Options API mistakes breaking component context and causing runtime errors for developers writing Vue 2 or Vue 3 components with the Options API.

About

vue-options-api-best-practices is an agent skill tagged HIGH impact that warns against using arrow functions for Options API lifecycle hooks in Vue 2 and Vue 3. Arrow functions lexically bind this from the enclosing scope, so Vue cannot bind this to the component instance in mounted, created, and similar hooks, leaving this undefined or pointing at the wrong context. That breaks access to component data, methods, and computed properties at runtime. The skill covers options-api lifecycle patterns with tags including vue3, vue2, lifecycle, arrow-functions, this-binding, mounted, and created. Developers reach for vue-options-api-best-practices when debugging mysterious undefined this errors in Options API components or reviewing legacy Vue codebases that mix arrow and function syntax in hooks.

  • Prevents `this` binding failures in lifecycle hooks
  • Enforces regular function syntax or ES6 method shorthand for created, mounted, updated, unmounted
  • Allows arrow functions only for nested callbacks inside hooks
  • HIGH impact rule set that eliminates undefined context bugs
  • Task checklist that agents can apply during code generation or review

Vue Options Api Best Practices by the numbers

  • 2,191 all-time installs (skills.sh)
  • +33 installs in the week ending Aug 5, 2026 (Skillselion tracking)
  • Security screen: LOW risk (skills.sh audit)
  • Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/hyf0/vue-skills --skill vue-options-api-best-practices

Add your badge

Show developers this skill is listed on Skillselion. Paste this into your README.

Listed on Skillselion
Installs2.2k
repo stars2.8k
Security audit3 / 3 scanners passed
Last updatedMay 30, 2026
Repositoryhyf0/vue-skills

Why is this undefined in Vue lifecycle hooks?

Prevent common Vue Options API mistakes that break component context and cause runtime errors.

Who is it for?

Vue developers using the Options API in Vue 2 or Vue 3 who hit undefined this errors in mounted, created, or other lifecycle hooks.

Skip if: Projects standardized on Vue Composition API with setup() where Options API lifecycle this-binding rules do not apply.

When should I use this skill?

The developer uses Vue Options API lifecycle hooks, sees undefined this at runtime, or asks about arrow functions in mounted or created.

What you get

Correct Options API lifecycle hook syntax with function declarations that preserve component this binding.

  • Corrected lifecycle hook patterns
  • Options API review guidance

By the numbers

  • Tagged HIGH impact for arrow function lifecycle hook mistakes

Files

SKILL.mdMarkdownGitHub ↗

Vue.js Options API best practices, TypeScript integration, and common gotchas.

TypeScript

  • Need to enable TypeScript type inference for component properties → See ts-options-api-use-definecomponent
  • Enabling type safety for Options API this context → See ts-strict-mode-options-api
  • Using old TypeScript versions with prop validators → See ts-options-api-arrow-functions-validators
  • Event handler parameters need proper type safety → See ts-options-api-type-event-handlers
  • Need to type object or array props with interfaces → See ts-options-api-proptype-complex-types
  • Injected properties missing TypeScript types completely → See ts-options-api-provide-inject-limitations
  • Complex computed properties lack clear type documentation → See ts-options-api-computed-return-types

Methods & Lifecycle

  • Methods aren't binding to component instance context → See no-arrow-functions-in-methods
  • Lifecycle hooks losing access to component data → See no-arrow-functions-in-lifecycle-hooks
  • Debounced functions sharing state across component instances → See stateful-methods-lifecycle

Related skills

How it compares

Pick vue-options-api-best-practices over general Vue skills when debugging Options API this-binding failures in lifecycle hooks specifically.

FAQ

Why should Vue lifecycle hooks avoid arrow functions?

Vue Options API lifecycle hooks should use regular functions because arrow functions lexically bind this from the outer scope. Vue cannot attach the component instance as this, so mounted and created hooks fail when accessing data, methods, or computed properties.

Does vue-options-api-best-practices apply to Composition API?

vue-options-api-best-practices targets the Options API in Vue 2 and Vue 3 where lifecycle hooks rely on instance this binding. Composition API code using setup() follows different patterns and is outside this skill's scope.

Is Vue Options Api Best Practices safe to install?

skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.

This week in AI coding

Five minutes, every Monday - the tools, releases and tactics for developers.

unsubscribe anytime.