本文へスキップ
Skillpedia
WebサイトとUI(フロントエンド)6.0k · #14442

pinia

できること

このスキルは、Vueの公式状態管理ライブラリであるPiniaを使って、Vueアプリの共有データを整理する方法を説明します。アプリの多くの部分で同じデータが必要な開発者のためのものです。

使う場面

  • ✓多くのコンポーネントでデータを共有する必要があるVueアプリを作っているとき。
  • ✓状態、ゲッター、アクションを持つストアを設定したいとき。
  • ✓Piniaのストアをテストまたは拡張する必要があるとき。

スキルのリンク

https://github.com/antfu/skills/blob/main/skills/pinia/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/antfu/skills/blob/main/skills/pinia/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“ショッピングカートの商品と合計金額をすべてのページで保持するPiniaストアを作ってください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは、共有データを保持するストアと、それを変更するアクションを設定します。型、テスト、拡張に関するPiniaの指針に従います。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Pinia

Pinia is the official state management library for Vue, designed to be intuitive and type-safe. It supports both Options API and Composition API styles, with first-class TypeScript support and devtools integration.

The skill is based on Pinia v4.0.3, generated at 2026-09-25.

Core References

Topic Description Reference
Stores Defining stores, state, getters, actions, storeToRefs, subscriptions core-stores

Features

Extensibility

Topic Description Reference
Plugins Extend stores with custom properties, state, and behavior features-plugins

Composability

Topic Description Reference
Composables Using Vue composables within stores (VueUse, etc.) features-composables
Composing Stores Store-to-store communication, avoiding circular dependencies features-composing-stores

Best Practices

Topic Description Reference
Testing Unit testing with @pinia/testing, mocking, stubbing best-practices-testing
Outside Components Using stores in navigation guards, plugins, middlewares best-practices-outside-component

Advanced

Topic Description Reference
SSR Server-side rendering, state hydration advanced-ssr
Nuxt Nuxt integration, auto-imports, SSR best practices advanced-nuxt
HMR Hot module replacement for development advanced-hmr

Key Recommendations

  • Prefer Setup Stores for complex logic, composables, and watchers
  • Use storeToRefs() when destructuring state/getters to preserve reactivity
  • Actions can be destructured directly - they're bound to the store
  • Call stores inside functions not at module scope, especially for SSR
  • Add HMR support to each store for better development experience
  • Use @pinia/testing for component tests with mocked stores
よくある質問

Piniaは Vue専用ですか?

はい。Vueアプリのために作られており、このスキルもそれを扱います。

ストアをテストできますか?

はい。ストアのテストとモックについても扱われています。

TypeScriptで使えますか?

はい。Piniaは型に安全に作られており、TypeScriptに対応しています。

詳細

作者による元の説明

Pinia official Vue state management library, type-safe and extensible. Use when defining stores, working with state/getters/actions, or implementing store patterns in Vue apps.

repo: antfu/skills

人気

GitHubのスター
6.0k
ランキング
#14442
ライセンス
MIT
更新日
2026/10/30

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル