Back to list
leeovery

nuxt-composables

by leeovery

1🍴 0📅 Jan 20, 2026

SKILL.md


name: nuxt-composables description: Creating custom Vue composables with proper patterns. Use when building reusable stateful logic, shared state management, or encapsulating feature-specific behavior.

Nuxt Composables

Creating reusable stateful logic via Vue Composition API.

Core Concepts

composables.md - Patterns, naming, state management, best practices

Singleton Pattern (Shared State)

State defined outside function persists across all callers:

// app/composables/useUser.ts
let user = ref<User>()  // Singleton - shared across app

export default function useUser() {
  const setUser = (data: BaseEntity) => {
    user.value = User.hydrate(data)
  }
  const clearUser = () => { user.value = undefined }

  return { user, setUser, clearUser }
}

Factory Pattern (Fresh State)

State defined inside function - new instance per call:

// app/composables/useCounter.ts
export default function useCounter(initial = 0) {
  const count = ref(initial)  // Fresh per call
  const increment = () => count.value++
  const decrement = () => count.value--

  return { count, increment, decrement }
}

Naming & File Conventions

ConventionExample
File nameuseUser.ts, useCategories.ts
Functionexport default function useUser()
ReturnAlways object { state, methods }
RefsReactive: user, not userRef

Score

Total Score

60/100

Based on repository quality metrics

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

Reviews

💬

Reviews coming soon